-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathExtremeValuesTests.cs
More file actions
126 lines (113 loc) · 6.64 KB
/
Copy pathExtremeValuesTests.cs
File metadata and controls
126 lines (113 loc) · 6.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
using NUnit.Framework;
using Wacton.Unicolour.Icc;
using Wacton.Unicolour.Tests.Utils;
namespace Wacton.Unicolour.Tests;
public class ExtremeValuesTests
{
[Test, Combinatorial]
public void CreateFromTriplet(
[ValueSource(typeof(TestUtils), nameof(TestUtils.AllColourSpaces))] ColourSpace colourSpace,
[ValueSource(typeof(TestUtils), nameof(TestUtils.ExtremeDoubles))] double first,
[ValueSource(typeof(TestUtils), nameof(TestUtils.ExtremeDoubles))] double second,
[ValueSource(typeof(TestUtils), nameof(TestUtils.ExtremeDoubles))] double third)
{
TestUtils.AssertNoPropertyError(new Unicolour(colourSpace, first, second, third));
TestUtils.AssertNoPropertyError(new Unicolour(TestUtils.DefaultFogra39Config, colourSpace, first, second, third));
}
[Test, Combinatorial]
public void CreateFromTripletWithAlpha(
[ValueSource(typeof(TestUtils), nameof(TestUtils.ExtremeDoubles))] double luminance,
[ValueSource(typeof(TestUtils), nameof(TestUtils.ExtremeDoubles))] double alpha)
{
TestUtils.AssertNoPropertyError(new Unicolour(ColourSpace.RgbLinear, luminance, luminance, luminance, alpha));
TestUtils.AssertNoPropertyError(new Unicolour(TestUtils.DefaultFogra39Config, ColourSpace.RgbLinear, luminance, luminance, luminance, alpha));
}
[Test, Combinatorial]
public void CreateFromHexWithAlpha(
[Values("#000000", "#798081", "#FFFFFF")] string hex,
[ValueSource(typeof(TestUtils), nameof(TestUtils.ExtremeDoubles))] double alpha)
{
TestUtils.AssertNoPropertyError(new Unicolour(hex, alpha));
TestUtils.AssertNoPropertyError(new Unicolour(TestUtils.DefaultFogra39Config, hex, alpha));
}
[Test, Combinatorial]
public void CreateFromChromaticity(
[ValueSource(typeof(TestUtils), nameof(TestUtils.ExtremeDoubles))] double x,
[ValueSource(typeof(TestUtils), nameof(TestUtils.ExtremeDoubles))] double y,
[ValueSource(typeof(TestUtils), nameof(TestUtils.ExtremeDoubles))] double luminance)
{
TestUtils.AssertNoPropertyError(new Unicolour(new Chromaticity(x, y), luminance));
TestUtils.AssertNoPropertyError(new Unicolour(TestUtils.DefaultFogra39Config, new Chromaticity(x, y), luminance));
}
[Test, Combinatorial]
public void CreateFromTemperature(
[ValueSource(typeof(TestUtils), nameof(TestUtils.ExtremeDoubles))] double cct,
[ValueSource(typeof(TestUtils), nameof(TestUtils.ExtremeDoubles))] double duv,
[ValueSource(typeof(TestUtils), nameof(TestUtils.ExtremeDoubles))] double luminance)
{
TestUtils.AssertNoPropertyError(new Unicolour(new Temperature(cct, duv), luminance));
TestUtils.AssertNoPropertyError(new Unicolour(TestUtils.DefaultFogra39Config, new Temperature(cct, duv), luminance));
}
[Test, Combinatorial]
public void CreateFromSpd(
[ValueSource(typeof(TestUtils), nameof(TestUtils.ExtremeDoubles))] double power1,
[ValueSource(typeof(TestUtils), nameof(TestUtils.ExtremeDoubles))] double power2,
[ValueSource(typeof(TestUtils), nameof(TestUtils.ExtremeDoubles))] double power3)
{
// -2147483647 nm = power1, 0 nm = power2, 2147483647 nm = power 3
var spd = new Spd(start: -int.MaxValue, interval: int.MaxValue, power1, power2, power3);
TestUtils.AssertNoPropertyError(new Unicolour(spd));
TestUtils.AssertNoPropertyError(new Unicolour(TestUtils.DefaultFogra39Config, spd));
}
[Test, Combinatorial]
public void CreateFromPigmentSingleConstant(
[ValueSource(typeof(TestUtils), nameof(TestUtils.ExtremeDoubles))] double coefficient,
[ValueSource(typeof(TestUtils), nameof(TestUtils.ExtremeDoubles))] double weight)
{
double[] coefficients = [coefficient, coefficient, coefficient];
var pigment = new Pigment(int.MinValue, int.MaxValue, coefficients);
TestUtils.AssertNoPropertyError(new Unicolour([pigment], [weight]));
TestUtils.AssertNoPropertyError(new Unicolour(TestUtils.DefaultFogra39Config, [pigment], [weight]));
}
[Test, Combinatorial]
public void CreateFromPigmentTwoConstant(
[ValueSource(typeof(TestUtils), nameof(TestUtils.ExtremeDoubles))] double coefficient,
[ValueSource(typeof(TestUtils), nameof(TestUtils.ExtremeDoubles))] double weight,
[ValueSource(typeof(TestUtils), nameof(TestUtils.ExtremeDoubles))] double correction)
{
double[] coefficients = [coefficient, coefficient, coefficient];
var pigment = new Pigment(int.MinValue, int.MaxValue, coefficients, coefficients, correction, correction);
TestUtils.AssertNoPropertyError(new Unicolour([pigment], [weight]));
TestUtils.AssertNoPropertyError(new Unicolour(TestUtils.DefaultFogra39Config, [pigment], [weight]));
}
[Test, Combinatorial]
public void CreateFromIcc(
[ValueSource(typeof(TestUtils), nameof(TestUtils.ExtremeDoubles))] double first,
[ValueSource(typeof(TestUtils), nameof(TestUtils.ExtremeDoubles))] double second,
[ValueSource(typeof(TestUtils), nameof(TestUtils.ExtremeDoubles))] double third,
[ValueSource(typeof(TestUtils), nameof(TestUtils.ExtremeDoubles))] double fourth)
{
TestUtils.AssertNoPropertyError(new Unicolour(new Channels(first, second, third, fourth)));
TestUtils.AssertNoPropertyError(new Unicolour(TestUtils.DefaultFogra39Config, new Channels(first, second, third, fourth)));
}
[Test, Combinatorial]
public void CreateFromIccWithAlpha(
[ValueSource(typeof(TestUtils), nameof(TestUtils.ExtremeDoubles))] double channel,
[ValueSource(typeof(TestUtils), nameof(TestUtils.ExtremeDoubles))] double alpha)
{
TestUtils.AssertNoPropertyError(new Unicolour(new Channels(channel, channel, channel, channel), alpha));
TestUtils.AssertNoPropertyError(new Unicolour(TestUtils.DefaultFogra39Config, new Channels(channel, channel, channel, channel), alpha));
}
[Test, Combinatorial]
public void Mix(
[ValueSource(typeof(TestUtils), nameof(TestUtils.AllColourSpaces))] ColourSpace colourSpace,
[ValueSource(typeof(TestUtils), nameof(TestUtils.ExtremeDoubles))] double amount)
{
var colour1 = Rng.Unicolour(colourSpace);
var colour2 = Rng.Unicolour(colourSpace);
TestUtils.AssertNoPropertyError(colour1.Mix(colour2, colourSpace, amount));
colour1 = Rng.Unicolour(colourSpace, TestUtils.DefaultFogra39Config);
colour2 = Rng.Unicolour(colourSpace, TestUtils.DefaultFogra39Config);
TestUtils.AssertNoPropertyError(colour1.Mix(colour2, colourSpace, amount));
}
}