Skip to content

Commit fc73a72

Browse files
committed
Add ByteConvertTest.
1 parent 465e445 commit fc73a72

File tree

3 files changed

+50
-1
lines changed

3 files changed

+50
-1
lines changed

MetadataExtractor.Tests/MetadataExtractor.Tests.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@
6868
<Compile Include="Formats\Png\PngMetadataReaderTest.cs" />
6969
<Compile Include="IO\ByteArrayReaderTest.cs" />
7070
<Compile Include="UseCultureAttribute.cs" />
71+
<Compile Include="Util\ByteConvertTest.cs" />
7172
<Compile Include="Util\ByteTrieTest.cs" />
7273
<Compile Include="GeoLocationTest.cs" />
7374
<Compile Include="IO\IndexedSeekingReaderTest.cs" />
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
#region License
2+
3+
//
4+
// Copyright 2002-2015 Drew Noakes
5+
// Ported from Java to C# by Yakov Danilov for Imazen LLC in 2014
6+
//
7+
// Licensed under the Apache License, Version 2.0 (the "License");
8+
// you may not use this file except in compliance with the License.
9+
// You may obtain a copy of the License at
10+
//
11+
// http://www.apache.org/licenses/LICENSE-2.0
12+
//
13+
// Unless required by applicable law or agreed to in writing, software
14+
// distributed under the License is distributed on an "AS IS" BASIS,
15+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
// See the License for the specific language governing permissions and
17+
// limitations under the License.
18+
//
19+
// More information about this project is available at:
20+
//
21+
// https://github.com/drewnoakes/metadata-extractor-dotnet
22+
// https://drewnoakes.com/code/exif/
23+
//
24+
25+
#endregion
26+
27+
using MetadataExtractor.Util;
28+
using Xunit;
29+
30+
namespace MetadataExtractor.Tests.Util
31+
{
32+
public class ByteConvertTest
33+
{
34+
[Fact]
35+
public void ToInt32BigEndian()
36+
{
37+
Assert.Equal(0x01020304, ByteConvert.ToInt32BigEndian(new byte[] { 1, 2, 3, 4 }));
38+
Assert.Equal(0x01020304, ByteConvert.ToInt32BigEndian(new byte[] { 1, 2, 3, 4, 5 }));
39+
}
40+
41+
[Fact]
42+
public void ToInt32LittleEndian()
43+
{
44+
Assert.Equal(0x04030201, ByteConvert.ToInt32LittleEndian(new byte[] { 1, 2, 3, 4 }));
45+
Assert.Equal(0x04030201, ByteConvert.ToInt32LittleEndian(new byte[] { 1, 2, 3, 4, 5 }));
46+
}
47+
}
48+
}

MetadataExtractor/Util/ByteConvert.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
namespace MetadataExtractor.Util
44
{
5-
internal static class ByteConvert
5+
public static class ByteConvert
66
{
77
[Pure]
88
public static int ToInt32BigEndian([NotNull] byte[] bytes)

0 commit comments

Comments
 (0)