Skip to content

Commit

Permalink
Add ByteConvertTest.
Browse files Browse the repository at this point in the history
  • Loading branch information
drewnoakes committed Jul 6, 2015
1 parent 465e445 commit fc73a72
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 1 deletion.
1 change: 1 addition & 0 deletions MetadataExtractor.Tests/MetadataExtractor.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
<Compile Include="Formats\Png\PngMetadataReaderTest.cs" />
<Compile Include="IO\ByteArrayReaderTest.cs" />
<Compile Include="UseCultureAttribute.cs" />
<Compile Include="Util\ByteConvertTest.cs" />
<Compile Include="Util\ByteTrieTest.cs" />
<Compile Include="GeoLocationTest.cs" />
<Compile Include="IO\IndexedSeekingReaderTest.cs" />
Expand Down
48 changes: 48 additions & 0 deletions MetadataExtractor.Tests/Util/ByteConvertTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#region License

//
// Copyright 2002-2015 Drew Noakes
// Ported from Java to C# by Yakov Danilov for Imazen LLC in 2014
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// More information about this project is available at:
//
// https://github.com/drewnoakes/metadata-extractor-dotnet
// https://drewnoakes.com/code/exif/
//

#endregion

using MetadataExtractor.Util;
using Xunit;

namespace MetadataExtractor.Tests.Util
{
public class ByteConvertTest
{
[Fact]
public void ToInt32BigEndian()
{
Assert.Equal(0x01020304, ByteConvert.ToInt32BigEndian(new byte[] { 1, 2, 3, 4 }));
Assert.Equal(0x01020304, ByteConvert.ToInt32BigEndian(new byte[] { 1, 2, 3, 4, 5 }));
}

[Fact]
public void ToInt32LittleEndian()
{
Assert.Equal(0x04030201, ByteConvert.ToInt32LittleEndian(new byte[] { 1, 2, 3, 4 }));
Assert.Equal(0x04030201, ByteConvert.ToInt32LittleEndian(new byte[] { 1, 2, 3, 4, 5 }));
}
}
}
2 changes: 1 addition & 1 deletion MetadataExtractor/Util/ByteConvert.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace MetadataExtractor.Util
{
internal static class ByteConvert
public static class ByteConvert
{
[Pure]
public static int ToInt32BigEndian([NotNull] byte[] bytes)
Expand Down

0 comments on commit fc73a72

Please sign in to comment.