Skip to content

Commit

Permalink
SixLabors#12 Mark tiff tests with "Tiff" category, cleanup test classes
Browse files Browse the repository at this point in the history
  • Loading branch information
IldarKhayrutdinov committed Aug 11, 2019
1 parent 77af83e commit 9be4966
Show file tree
Hide file tree
Showing 17 changed files with 82 additions and 88 deletions.
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.

using System.Collections.Generic;
using SixLabors.ImageSharp.Formats.Tiff;
using SixLabors.ImageSharp.PixelFormats;
using Xunit;

namespace SixLabors.ImageSharp.Tests
{
using System.Collections.Generic;
using Xunit;

using ImageSharp.Formats.Tiff;

[Trait("Category", "Tiff")]
public class BlackIsZeroTiffColorTests : PhotometricInterpretationTestBase
{
private static Rgba32 Gray000 = new Rgba32(0, 0, 0, 255);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ namespace SixLabors.ImageSharp.Tests

using ImageSharp.Formats.Tiff;

[Trait("Category", "Tiff")]
public class PaletteTiffColorTests : PhotometricInterpretationTestBase
{
public static uint[][] Palette4_ColorPalette { get => GeneratePalette(16); }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ namespace SixLabors.ImageSharp.Tests
using ImageSharp;
using SixLabors.ImageSharp.Memory;

[Trait("Category", "Tiff")]
public abstract class PhotometricInterpretationTestBase
{
public static Rgba32 DefaultColor = new Rgba32(42, 96, 18, 128);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ namespace SixLabors.ImageSharp.Tests

using ImageSharp.Formats.Tiff;

[Trait("Category", "Tiff")]
public class RgbPlanarTiffColorTests : PhotometricInterpretationTestBase
{
private static Rgba32 Rgb4_000 = new Rgba32(0, 0, 0, 255);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ namespace SixLabors.ImageSharp.Tests

using ImageSharp.Formats.Tiff;

[Trait("Category", "Tiff")]
public class RgbTiffColorTests : PhotometricInterpretationTestBase
{
private static Rgba32 Rgb4_000 = new Rgba32(0, 0, 0, 255);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ namespace SixLabors.ImageSharp.Tests

using ImageSharp.Formats.Tiff;

[Trait("Category", "Tiff")]
public class WhiteIsZeroTiffColorTests : PhotometricInterpretationTestBase
{
private static Rgba32 Gray000 = new Rgba32(255, 255, 255, 255);
Expand Down
9 changes: 4 additions & 5 deletions tests/ImageSharp.Tests/Formats/Tiff/TiffDecoderHeaderTests.cs
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.

using System.IO;
using SixLabors.ImageSharp.Formats.Tiff;
using SixLabors.ImageSharp.PixelFormats;
using Xunit;

namespace SixLabors.ImageSharp.Tests
{
using System.IO;
using Xunit;

using ImageSharp.Formats;

[Trait("Category", "Tiff")]
public class TiffDecoderHeaderTests
{
public static object[][] IsLittleEndianValues = new[] { new object[] { false },
Expand Down
41 changes: 20 additions & 21 deletions tests/ImageSharp.Tests/Formats/Tiff/TiffDecoderIfdEntryTests.cs
Original file line number Diff line number Diff line change
@@ -1,19 +1,16 @@
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.

using System;
using System.IO;
using System.Linq;
using SixLabors.ImageSharp.Formats.Tiff;
using SixLabors.ImageSharp.Primitives;
using Xunit;

namespace SixLabors.ImageSharp.Tests
{
using System;
using System.IO;
using System.Linq;
using Xunit;

using ImageSharp.Formats;
using ImageSharp.Formats.Tiff;

using SixLabors.ImageSharp.MetaData.Profiles.Exif;
using SixLabors.ImageSharp.Primitives;

[Trait("Category", "Tiff")]
public class TiffDecoderIfdEntryTests
{
[Theory]
Expand Down Expand Up @@ -88,9 +85,11 @@ public void ReadBytes_ReturnsExpectedData(ushort type, uint count, byte[] bytes,
(TiffDecoderCore decoder, TiffIfdEntry entry) = GenerateTestIfdEntry(TiffGenEntry.Bytes(TiffTags.ImageWidth, (TiffType)type, count, bytes), isLittleEndian);

byte[] result = decoder.ReadBytes(ref entry);

if (bytes.Length < 4)
{
result = result.Take(bytes.Length).ToArray();
}

Assert.Equal(bytes, result);
}
Expand All @@ -113,7 +112,7 @@ public void ReadBytes_CachesDataLongerThanFourBytes(ushort type, uint count, byt
Assert.Equal(4, entry.Value.Length);

byte[] result = decoder.ReadBytes(ref entry);

Assert.Equal(bytes.Length, entry.Value.Length);
Assert.Equal(bytes, entry.Value);
}
Expand Down Expand Up @@ -154,7 +153,7 @@ public void ReadUnsignedInteger_ReturnsValue(ushort type, bool isLittleEndian, b
(TiffDecoderCore decoder, TiffIfdEntry entry) = GenerateTestIfdEntry(TiffGenEntry.Bytes(TiffTags.ImageWidth, (TiffType)type, 1, bytes), isLittleEndian);

uint result = decoder.ReadUnsignedInteger(ref entry);

Assert.Equal(expectedValue, result);
}

Expand Down Expand Up @@ -231,7 +230,7 @@ public void ReadSignedInteger_ReturnsValue(ushort type, bool isLittleEndian, byt
(TiffDecoderCore decoder, TiffIfdEntry entry) = GenerateTestIfdEntry(TiffGenEntry.Bytes(TiffTags.ImageWidth, (TiffType)type, 1, bytes), isLittleEndian);

int result = decoder.ReadSignedInteger(ref entry);

Assert.Equal(expectedValue, result);
}

Expand Down Expand Up @@ -294,7 +293,7 @@ public void ReadUnsignedIntegerArray_ReturnsValue(ushort type, int count, bool i
(TiffDecoderCore decoder, TiffIfdEntry entry) = GenerateTestIfdEntry(TiffGenEntry.Bytes(TiffTags.ImageWidth, (TiffType)type, (uint)expectedValue.Length, bytes), isLittleEndian);

uint[] result = decoder.ReadUnsignedIntegerArray(ref entry);

Assert.Equal(expectedValue, result);
}

Expand Down Expand Up @@ -341,7 +340,7 @@ public void ReadSignedIntegerArray_ReturnsValue(ushort type, int count, bool isL
(TiffDecoderCore decoder, TiffIfdEntry entry) = GenerateTestIfdEntry(TiffGenEntry.Bytes(TiffTags.ImageWidth, (TiffType)type, (uint)expectedValue.Length, bytes), isLittleEndian);

int[] result = decoder.ReadSignedIntegerArray(ref entry);

Assert.Equal(expectedValue, result);
}

Expand Down Expand Up @@ -380,7 +379,7 @@ public void ReadString_ReturnsValue(bool isLittleEndian, byte[] bytes, string ex
(TiffDecoderCore decoder, TiffIfdEntry entry) = GenerateTestIfdEntry(TiffGenEntry.Bytes(TiffTags.ImageWidth, TiffType.Ascii, (uint)bytes.Length, bytes), isLittleEndian);

string result = decoder.ReadString(ref entry);

Assert.Equal(expectedValue, result);
}

Expand Down Expand Up @@ -829,12 +828,12 @@ public void ReadDoubleArray_ThrowsExceptionIfInvalidType(ushort type)
private (TiffDecoderCore, TiffIfdEntry) GenerateTestIfdEntry(TiffGenEntry entry, bool isLittleEndian)
{
Stream stream = new TiffGenIfd()
{
Entries =
{
Entries =
{
entry
}
}
}
.ToStream(isLittleEndian);

TiffDecoderCore decoder = new TiffDecoderCore(stream, isLittleEndian, null, null);
Expand Down
11 changes: 5 additions & 6 deletions tests/ImageSharp.Tests/Formats/Tiff/TiffDecoderIfdTests.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.

using System.IO;
using SixLabors.ImageSharp.Formats.Tiff;
using Xunit;

namespace SixLabors.ImageSharp.Tests
{
using System.IO;
using Xunit;

using ImageSharp.Formats;
using ImageSharp.Formats.Tiff;

[Trait("Category", "Tiff")]
public class TiffDecoderIfdTests
{
public static object[][] IsLittleEndianValues = new[] { new object[] { false },
Expand Down
12 changes: 5 additions & 7 deletions tests/ImageSharp.Tests/Formats/Tiff/TiffDecoderImageTests.cs
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.

using System;
using System.IO;
using SixLabors.ImageSharp.Formats.Tiff;
using SixLabors.ImageSharp.PixelFormats;
using Xunit;

namespace SixLabors.ImageSharp.Tests
{
using System;
using System.IO;
using Xunit;

using ImageSharp.Formats;
using ImageSharp.Formats.Tiff;

[Trait("Category", "Tiff")]
public class TiffDecoderImageTests
{
public const int ImageWidth = 200;
Expand Down
12 changes: 5 additions & 7 deletions tests/ImageSharp.Tests/Formats/Tiff/TiffDecoderMetadataTests.cs
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.

using System.IO;
using System.Linq;
using SixLabors.ImageSharp.Formats.Tiff;
using SixLabors.ImageSharp.PixelFormats;
using Xunit;

namespace SixLabors.ImageSharp.Tests
{
using System.IO;
using System.Linq;
using Xunit;

using ImageSharp.Formats;
using ImageSharp.Formats.Tiff;

[Trait("Category", "Tiff")]
public class TiffDecoderMetadataTests
{
public static object[][] BaselineMetadataValues = new[] { new object[] { false, TiffTags.Artist, TiffMetadataNames.Artist, "My Artist Name" },
Expand Down
12 changes: 5 additions & 7 deletions tests/ImageSharp.Tests/Formats/Tiff/TiffEncoderHeaderTests.cs
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.

using System.IO;
using SixLabors.ImageSharp.Formats.Tiff;
using Xunit;

namespace SixLabors.ImageSharp.Tests
{
using System.IO;

using Xunit;

using ImageSharp.Formats;
using ImageSharp.Formats.Tiff;

[Trait("Category", "Tiff")]
public class TiffEncoderHeaderTests
{
[Fact]
Expand Down
18 changes: 8 additions & 10 deletions tests/ImageSharp.Tests/Formats/Tiff/TiffEncoderIfdTests.cs
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using SixLabors.ImageSharp.Formats.Tiff;
using Xunit;

namespace SixLabors.ImageSharp.Tests
{
using System;
using System.IO;
using System.Linq;
using Xunit;

using ImageSharp.Formats;
using ImageSharp.Formats.Tiff;

using System.Collections.Generic;

[Trait("Category", "Tiff")]
public class TiffEncoderIfdTests
{
[Fact]
Expand Down
16 changes: 6 additions & 10 deletions tests/ImageSharp.Tests/Formats/Tiff/TiffEncoderMetadataTests.cs
Original file line number Diff line number Diff line change
@@ -1,20 +1,16 @@
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.

using System.Collections.Generic;
using SixLabors.ImageSharp.Formats.Tiff;
using SixLabors.ImageSharp.MetaData;
using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Primitives;
using Xunit;

namespace SixLabors.ImageSharp.Tests
{
using Xunit;

using ImageSharp.Formats;
using ImageSharp.Formats.Tiff;
using System.Collections.Generic;

using SixLabors.ImageSharp.MetaData;
using SixLabors.ImageSharp.MetaData.Profiles.Exif;
using SixLabors.ImageSharp.Primitives;

[Trait("Category", "Tiff")]
public class TiffEncoderMetadataTests
{
public static object[][] BaselineMetadataValues = new[] { new object[] { TiffTags.Artist, TiffMetadataNames.Artist, "My Artist Name" },
Expand Down
8 changes: 4 additions & 4 deletions tests/ImageSharp.Tests/Formats/Tiff/TiffFormatTests.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.

using SixLabors.ImageSharp.Formats.Tiff;
using Xunit;

namespace SixLabors.ImageSharp.Tests
{
using Xunit;

using ImageSharp.Formats;

[Trait("Category", "Tiff")]
public class TiffFormatTests
{
[Fact]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.

using System.Linq;
using SixLabors.ImageSharp.Formats.Tiff;
using Xunit;

namespace SixLabors.ImageSharp.Tests
{
using System.Linq;
using Xunit;

using ImageSharp.Formats;

[Trait("Category", "Tiff")]
public class TiffImageFormatDetectorTests
{
public static object[][] IsLittleEndianValues = new[] { new object[] { false },
Expand Down
Loading

0 comments on commit 9be4966

Please sign in to comment.