mirror of https://github.com/SixLabors/ImageSharp
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
114 lines
3.3 KiB
114 lines
3.3 KiB
// <copyright file="IccDataWriterTests.cs" company="James Jackson-South">
|
|
// Copyright (c) James Jackson-South and contributors.
|
|
// Licensed under the Apache License, Version 2.0.
|
|
// </copyright>
|
|
|
|
namespace ImageSharp.Tests.Icc
|
|
{
|
|
using Xunit;
|
|
|
|
public class IccDataWriterTests
|
|
{
|
|
[Fact]
|
|
public void WriteEmpty()
|
|
{
|
|
IccDataWriter writer = CreateWriter();
|
|
|
|
writer.WriteEmpty(4);
|
|
byte[] output = writer.GetData();
|
|
|
|
Assert.Equal(new byte[4], output);
|
|
}
|
|
|
|
[Theory]
|
|
[InlineData(1, 4)]
|
|
[InlineData(4, 4)]
|
|
public void WritePadding(int writePosition, int expectedLength)
|
|
{
|
|
IccDataWriter writer = CreateWriter();
|
|
|
|
writer.WriteEmpty(writePosition);
|
|
writer.WritePadding();
|
|
byte[] output = writer.GetData();
|
|
|
|
Assert.Equal(new byte[expectedLength], output);
|
|
}
|
|
|
|
[Theory]
|
|
[MemberData(nameof(IccTestDataArray.UInt8TestData), MemberType = typeof(IccTestDataArray))]
|
|
public void WriteArrayUInt8(byte[] data, byte[] expected)
|
|
{
|
|
IccDataWriter writer = CreateWriter();
|
|
|
|
writer.WriteArray(data);
|
|
byte[] output = writer.GetData();
|
|
|
|
Assert.Equal(expected, output);
|
|
}
|
|
|
|
[Theory]
|
|
[MemberData(nameof(IccTestDataArray.UInt16TestData), MemberType = typeof(IccTestDataArray))]
|
|
public void WriteArrayUInt16(byte[] expected, ushort[] data)
|
|
{
|
|
IccDataWriter writer = CreateWriter();
|
|
|
|
writer.WriteArray(data);
|
|
byte[] output = writer.GetData();
|
|
|
|
Assert.Equal(expected, output);
|
|
}
|
|
|
|
[Theory]
|
|
[MemberData(nameof(IccTestDataArray.Int16TestData), MemberType = typeof(IccTestDataArray))]
|
|
public void WriteArrayInt16(byte[] expected, short[] data)
|
|
{
|
|
IccDataWriter writer = CreateWriter();
|
|
|
|
writer.WriteArray(data);
|
|
byte[] output = writer.GetData();
|
|
|
|
Assert.Equal(expected, output);
|
|
}
|
|
|
|
[Theory]
|
|
[MemberData(nameof(IccTestDataArray.UInt32TestData), MemberType = typeof(IccTestDataArray))]
|
|
public void WriteArrayUInt32(byte[] expected, uint[] data)
|
|
{
|
|
IccDataWriter writer = CreateWriter();
|
|
|
|
writer.WriteArray(data);
|
|
byte[] output = writer.GetData();
|
|
|
|
Assert.Equal(expected, output);
|
|
}
|
|
|
|
[Theory]
|
|
[MemberData(nameof(IccTestDataArray.Int32TestData), MemberType = typeof(IccTestDataArray))]
|
|
public void WriteArrayInt32(byte[] expected, int[] data)
|
|
{
|
|
IccDataWriter writer = CreateWriter();
|
|
|
|
writer.WriteArray(data);
|
|
byte[] output = writer.GetData();
|
|
|
|
Assert.Equal(expected, output);
|
|
}
|
|
|
|
[Theory]
|
|
[MemberData(nameof(IccTestDataArray.UInt64TestData), MemberType = typeof(IccTestDataArray))]
|
|
public void WriteArrayUInt64(byte[] expected, ulong[] data)
|
|
{
|
|
IccDataWriter writer = CreateWriter();
|
|
|
|
writer.WriteArray(data);
|
|
byte[] output = writer.GetData();
|
|
|
|
Assert.Equal(expected, output);
|
|
}
|
|
|
|
private IccDataWriter CreateWriter()
|
|
{
|
|
return new IccDataWriter();
|
|
}
|
|
}
|
|
}
|
|
|