Browse Source

improve information locality for BmpDecoderTests

pull/469/head
Anton Firszov 8 years ago
parent
commit
46368a9fa7
  1. 35
      tests/ImageSharp.Tests/Formats/Bmp/BmpDecoderTests.cs

35
tests/ImageSharp.Tests/Formats/Bmp/BmpDecoderTests.cs

@ -1,19 +1,28 @@
// Copyright (c) Six Labors and contributors. // Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0. // Licensed under the Apache License, Version 2.0.
using SixLabors.ImageSharp.Formats; using System.IO;
using SixLabors.ImageSharp.Formats.Bmp;
using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.PixelFormats;
using Xunit; using Xunit;
// ReSharper disable InconsistentNaming // ReSharper disable InconsistentNaming
namespace SixLabors.ImageSharp.Tests namespace SixLabors.ImageSharp.Tests
{ {
using System.IO;
using static TestImages.Bmp;
using SixLabors.ImageSharp.Formats.Bmp;
public class BmpDecoderTests : FileTestBase public class BmpDecoderTests
{ {
public const PixelTypes CommonNonDefaultPixelTypes =
PixelTypes.Rgba32 | PixelTypes.Bgra32 | PixelTypes.RgbaVector;
public static readonly string[] AllBmpFiles =
{
Car, F, NegHeight, CoreHeader, V5Header, RLE, RLEInverted, Bit8, Bit8Inverted, Bit16, Bit16Inverted
};
[Theory] [Theory]
[WithFileCollection(nameof(AllBmpFiles), PixelTypes.Rgba32)] [WithFileCollection(nameof(AllBmpFiles), PixelTypes.Rgba32)]
public void DecodeBmp<TPixel>(TestImageProvider<TPixel> provider) public void DecodeBmp<TPixel>(TestImageProvider<TPixel> provider)
@ -27,7 +36,7 @@ namespace SixLabors.ImageSharp.Tests
} }
[Theory] [Theory]
[WithFile(TestImages.Bmp.F, CommonNonDefaultPixelTypes)] [WithFile(F, CommonNonDefaultPixelTypes)]
public void BmpDecoder_IsNotBoundToSinglePixelType<TPixel>(TestImageProvider<TPixel> provider) public void BmpDecoder_IsNotBoundToSinglePixelType<TPixel>(TestImageProvider<TPixel> provider)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
{ {
@ -39,18 +48,18 @@ namespace SixLabors.ImageSharp.Tests
} }
[Theory] [Theory]
[InlineData(TestImages.Bmp.Car, 24)] [InlineData(Car, 24)]
[InlineData(TestImages.Bmp.F, 24)] [InlineData(F, 24)]
[InlineData(TestImages.Bmp.NegHeight, 24)] [InlineData(NegHeight, 24)]
[InlineData(TestImages.Bmp.Bit8, 8)] [InlineData(Bit8, 8)]
[InlineData(TestImages.Bmp.Bit8Inverted, 8)] [InlineData(Bit8Inverted, 8)]
public void DetectPixelSize(string imagePath, int expectedPixelSize) public void DetectPixelSize(string imagePath, int expectedPixelSize)
{ {
TestFile testFile = TestFile.Create(imagePath); var testFile = TestFile.Create(imagePath);
using (var stream = new MemoryStream(testFile.Bytes, false)) using (var stream = new MemoryStream(testFile.Bytes, false))
{ {
Assert.Equal(expectedPixelSize, Image.Identify(stream)?.PixelType?.BitsPerPixel); Assert.Equal(expectedPixelSize, Image.Identify(stream)?.PixelType?.BitsPerPixel);
} }
} }
} }
} }
Loading…
Cancel
Save