diff --git a/MetadataExtractor.Tests/MetadataExtractor.Tests.csproj b/MetadataExtractor.Tests/MetadataExtractor.Tests.csproj index 836cd9194..a50d9cbe0 100644 --- a/MetadataExtractor.Tests/MetadataExtractor.Tests.csproj +++ b/MetadataExtractor.Tests/MetadataExtractor.Tests.csproj @@ -68,6 +68,7 @@ + diff --git a/MetadataExtractor.Tests/Util/ByteConvertTest.cs b/MetadataExtractor.Tests/Util/ByteConvertTest.cs new file mode 100644 index 000000000..a115ab2cd --- /dev/null +++ b/MetadataExtractor.Tests/Util/ByteConvertTest.cs @@ -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 })); + } + } +} \ No newline at end of file diff --git a/MetadataExtractor/Util/ByteConvert.cs b/MetadataExtractor/Util/ByteConvert.cs index 627109bbb..3771faa2c 100644 --- a/MetadataExtractor/Util/ByteConvert.cs +++ b/MetadataExtractor/Util/ByteConvert.cs @@ -2,7 +2,7 @@ namespace MetadataExtractor.Util { - internal static class ByteConvert + public static class ByteConvert { [Pure] public static int ToInt32BigEndian([NotNull] byte[] bytes)