Skip to content

Commit bdc5795

Browse files
committed
Renamed methods in unit test.
1 parent c7244d9 commit bdc5795

File tree

1 file changed

+67
-67
lines changed

1 file changed

+67
-67
lines changed

tests/Magick.NET.Tests/MagickImageTests/ThePerceptualHashMethod.cs

Lines changed: 67 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public void ShouldThrowExceptionWhenTooMuchColorSpacesAreProvided()
3333
}
3434

3535
[Fact]
36-
public void ShouldRemoveDuplicateColorSpaces()
36+
public void ShouldThrowExceptionWhenDuplicateColorSpacesAreProvided()
3737
{
3838
using var image = new MagickImage(Files.ImageMagickJPG);
3939
Assert.Throws<ArgumentException>("colorSpaces", () => image.PerceptualHash(ColorSpace.CMY, ColorSpace.CMY));
@@ -49,94 +49,94 @@ public void ShouldReturnThePerceptualHash()
4949
var channel = phash.GetChannel(PixelChannel.Red);
5050

5151
#if Q8
52-
TestChannel(channel, 0, 0.2609, 0.2609, 0.0975, 0.0993);
53-
TestChannel(channel, 1, 3.2660, 3.2659, 0.6583, 0.6686);
54-
TestChannel(channel, 2, 3.5858, 3.5854, 0.9238, 0.9196);
55-
TestChannel(channel, 3, 3.6612, 3.6610, 2.3627, 2.3355);
56-
TestChannel(channel, 4, 7.3919, 7.3918, 4.9577, 5.2277);
57-
TestChannel(channel, 5, 6.1101, 6.1107, 2.8422, 2.8360);
58-
TestChannel(channel, 6, 7.4893, 7.4885, 4.0087, 3.9636);
52+
AssertChannel(channel, 0, 0.2609, 0.2609, 0.0975, 0.0993);
53+
AssertChannel(channel, 1, 3.2660, 3.2659, 0.6583, 0.6686);
54+
AssertChannel(channel, 2, 3.5858, 3.5854, 0.9238, 0.9196);
55+
AssertChannel(channel, 3, 3.6612, 3.6610, 2.3627, 2.3355);
56+
AssertChannel(channel, 4, 7.3919, 7.3918, 4.9577, 5.2277);
57+
AssertChannel(channel, 5, 6.1101, 6.1107, 2.8422, 2.8360);
58+
AssertChannel(channel, 6, 7.4893, 7.4885, 4.0087, 3.9636);
5959
#elif Q16
60-
TestChannel(channel, 0, 0.2600, 0.2600, 0.2576, 0.2570);
61-
TestChannel(channel, 1, 3.2672, 3.2672, 1.0621, 1.0553);
62-
TestChannel(channel, 2, 3.5845, 3.5845, 1.3757, 1.3801);
63-
TestChannel(channel, 3, 3.6533, 3.6533, 2.8341, 2.8361);
64-
TestChannel(channel, 4, 7.3710, 7.3710, 5.1136, 5.1087);
65-
TestChannel(channel, 5, 6.0810, 6.0810, 3.4792, 3.4734);
66-
TestChannel(channel, 6, 7.4909, 7.4909, 5.0677, 5.0815);
60+
AssertChannel(channel, 0, 0.2600, 0.2600, 0.2576, 0.2570);
61+
AssertChannel(channel, 1, 3.2672, 3.2672, 1.0621, 1.0553);
62+
AssertChannel(channel, 2, 3.5845, 3.5845, 1.3757, 1.3801);
63+
AssertChannel(channel, 3, 3.6533, 3.6533, 2.8341, 2.8361);
64+
AssertChannel(channel, 4, 7.3710, 7.3710, 5.1136, 5.1087);
65+
AssertChannel(channel, 5, 6.0810, 6.0810, 3.4792, 3.4734);
66+
AssertChannel(channel, 6, 7.4909, 7.4909, 5.0677, 5.0815);
6767
#else
68-
TestChannel(channel, 0, 0.2600, 0.2600, 0.2948, 0.2946);
69-
TestChannel(channel, 1, 3.2673, 3.2673, 1.1852, 1.1834);
70-
TestChannel(channel, 2, 3.5845, 3.5845, 1.5017, 1.5010);
71-
TestChannel(channel, 3, 3.6533, 3.6533, 3.0470, 3.0420);
72-
TestChannel(channel, 4, 7.3708, 7.3708, 5.3762, 5.3652);
73-
TestChannel(channel, 5, 6.0808, 6.0808, 3.6754, 3.6675);
74-
TestChannel(channel, 6, 7.4910, 7.4910, 5.6470, 5.6501);
68+
AssertChannel(channel, 0, 0.2600, 0.2600, 0.2948, 0.2946);
69+
AssertChannel(channel, 1, 3.2673, 3.2673, 1.1852, 1.1834);
70+
AssertChannel(channel, 2, 3.5845, 3.5845, 1.5017, 1.5010);
71+
AssertChannel(channel, 3, 3.6533, 3.6533, 3.0470, 3.0420);
72+
AssertChannel(channel, 4, 7.3708, 7.3708, 5.3762, 5.3652);
73+
AssertChannel(channel, 5, 6.0808, 6.0808, 3.6754, 3.6675);
74+
AssertChannel(channel, 6, 7.4910, 7.4910, 5.6470, 5.6501);
7575
#endif
7676

7777
channel = phash.GetChannel(PixelChannel.Green);
7878

7979
#if Q8
80-
TestChannel(channel, 0, 0.2623, 0.2623, 0.0637, 0.0637);
81-
TestChannel(channel, 1, 2.9570, 2.9572, 0.6035, 0.6036);
82-
TestChannel(channel, 2, 3.2478, 3.2475, 0.9510, 0.9508);
83-
TestChannel(channel, 3, 3.5946, 3.5946, 1.1194, 1.1199);
84-
TestChannel(channel, 4, 7.3861, 7.3853, 2.5013, 2.5020);
85-
TestChannel(channel, 5, 5.7001, 5.6994, 1.4568, 1.4574);
86-
TestChannel(channel, 6, 7.0594, 7.0594, 2.2038, 2.2044);
80+
AssertChannel(channel, 0, 0.2623, 0.2623, 0.0637, 0.0637);
81+
AssertChannel(channel, 1, 2.9570, 2.9572, 0.6035, 0.6036);
82+
AssertChannel(channel, 2, 3.2478, 3.2475, 0.9510, 0.9508);
83+
AssertChannel(channel, 3, 3.5946, 3.5946, 1.1194, 1.1199);
84+
AssertChannel(channel, 4, 7.3861, 7.3853, 2.5013, 2.5020);
85+
AssertChannel(channel, 5, 5.7001, 5.6994, 1.4568, 1.4574);
86+
AssertChannel(channel, 6, 7.0594, 7.0594, 2.2038, 2.2044);
8787
#elif Q16
88-
TestChannel(channel, 0, 0.2620, 0.2620, 0.0635, 0.0635);
89-
TestChannel(channel, 1, 2.9595, 2.9595, 0.6031, 0.6031);
90-
TestChannel(channel, 2, 3.2481, 3.2481, 0.9501, 0.9501);
91-
TestChannel(channel, 3, 3.5937, 3.5937, 1.1202, 1.1202);
92-
TestChannel(channel, 4, 7.3773, 7.3773, 2.5015, 2.5015);
93-
TestChannel(channel, 5, 5.6952, 5.6952, 1.4575, 1.4575);
94-
TestChannel(channel, 6, 7.0599, 7.0599, 2.2046, 2.2046);
88+
AssertChannel(channel, 0, 0.2620, 0.2620, 0.0635, 0.0635);
89+
AssertChannel(channel, 1, 2.9595, 2.9595, 0.6031, 0.6031);
90+
AssertChannel(channel, 2, 3.2481, 3.2481, 0.9501, 0.9501);
91+
AssertChannel(channel, 3, 3.5937, 3.5937, 1.1202, 1.1202);
92+
AssertChannel(channel, 4, 7.3773, 7.3773, 2.5015, 2.5015);
93+
AssertChannel(channel, 5, 5.6952, 5.6952, 1.4575, 1.4575);
94+
AssertChannel(channel, 6, 7.0599, 7.0599, 2.2046, 2.2046);
9595
#else
96-
TestChannel(channel, 0, 0.2620, 0.2620, 0.0635, 0.0635);
97-
TestChannel(channel, 1, 2.9595, 2.9595, 0.6031, 0.6031);
98-
TestChannel(channel, 2, 3.2481, 3.2481, 0.9501, 0.9501);
99-
TestChannel(channel, 3, 3.5937, 3.5937, 1.1202, 1.1202);
100-
TestChannel(channel, 4, 7.3771, 7.3771, 2.5015, 2.5015);
101-
TestChannel(channel, 5, 5.6950, 5.6950, 1.4575, 1.4575);
102-
TestChannel(channel, 6, 7.0599, 7.0599, 2.2046, 2.2046);
96+
AssertChannel(channel, 0, 0.2620, 0.2620, 0.0635, 0.0635);
97+
AssertChannel(channel, 1, 2.9595, 2.9595, 0.6031, 0.6031);
98+
AssertChannel(channel, 2, 3.2481, 3.2481, 0.9501, 0.9501);
99+
AssertChannel(channel, 3, 3.5937, 3.5937, 1.1202, 1.1202);
100+
AssertChannel(channel, 4, 7.3771, 7.3771, 2.5015, 2.5015);
101+
AssertChannel(channel, 5, 5.6950, 5.6950, 1.4575, 1.4575);
102+
AssertChannel(channel, 6, 7.0599, 7.0599, 2.2046, 2.2046);
103103
#endif
104104

105105
channel = phash.GetChannel(PixelChannel.Blue);
106106

107107
#if Q8
108-
TestChannel(channel, 0, 0.6559, 0.6560, 0.7381, 0.7381);
109-
TestChannel(channel, 1, 3.1032, 3.1035, 4.0987, 4.0989);
110-
TestChannel(channel, 2, 3.7201, 3.7202, 4.9907, 4.9905);
111-
TestChannel(channel, 3, 3.9978, 3.9979, 5.1225, 5.1225);
112-
TestChannel(channel, 4, 7.8604, 7.8607, 10.1991, 10.1992);
113-
TestChannel(channel, 5, 5.8126, 5.8133, 7.2674, 7.2678);
114-
TestChannel(channel, 6, 8.7449, 8.7418, 10.7076, 10.7048);
108+
AssertChannel(channel, 0, 0.6559, 0.6560, 0.7381, 0.7381);
109+
AssertChannel(channel, 1, 3.1032, 3.1035, 4.0987, 4.0989);
110+
AssertChannel(channel, 2, 3.7201, 3.7202, 4.9907, 4.9905);
111+
AssertChannel(channel, 3, 3.9978, 3.9979, 5.1225, 5.1225);
112+
AssertChannel(channel, 4, 7.8604, 7.8607, 10.1991, 10.1992);
113+
AssertChannel(channel, 5, 5.8126, 5.8133, 7.2674, 7.2678);
114+
AssertChannel(channel, 6, 8.7449, 8.7418, 10.7076, 10.7048);
115115
#elif Q16
116-
TestChannel(channel, 0, 0.6558, 0.6558, 0.7381, 0.7381);
117-
TestChannel(channel, 1, 3.1021, 3.1021, 4.0982, 4.0982);
118-
TestChannel(channel, 2, 3.7194, 3.7194, 4.9910, 4.9910);
119-
TestChannel(channel, 3, 3.9968, 3.9968, 5.1224, 5.1224);
120-
TestChannel(channel, 4, 7.8585, 7.8585, 10.1987, 10.1987);
121-
TestChannel(channel, 5, 5.8103, 5.8103, 7.2667, 7.2667);
122-
TestChannel(channel, 6, 8.7491, 8.7491, 10.7102, 10.7102);
116+
AssertChannel(channel, 0, 0.6558, 0.6558, 0.7381, 0.7381);
117+
AssertChannel(channel, 1, 3.1021, 3.1021, 4.0982, 4.0982);
118+
AssertChannel(channel, 2, 3.7194, 3.7194, 4.9910, 4.9910);
119+
AssertChannel(channel, 3, 3.9968, 3.9968, 5.1224, 5.1224);
120+
AssertChannel(channel, 4, 7.8585, 7.8585, 10.1987, 10.1987);
121+
AssertChannel(channel, 5, 5.8103, 5.8103, 7.2667, 7.2667);
122+
AssertChannel(channel, 6, 8.7491, 8.7491, 10.7102, 10.7102);
123123
#else
124-
TestChannel(channel, 0, 0.6558, 0.6558, 0.7381, 0.7381);
125-
TestChannel(channel, 1, 3.1021, 3.1021, 4.0982, 4.0982);
126-
TestChannel(channel, 2, 3.7194, 3.7194, 4.9910, 4.9910);
127-
TestChannel(channel, 3, 3.9968, 3.9968, 5.1224, 5.1224);
128-
TestChannel(channel, 4, 7.8585, 7.8585, 10.1987, 10.1987);
129-
TestChannel(channel, 5, 5.8103, 5.8103, 7.2667, 7.2667);
130-
TestChannel(channel, 6, 8.7491, 8.7491, 10.7102, 10.7102);
124+
AssertChannel(channel, 0, 0.6558, 0.6558, 0.7381, 0.7381);
125+
AssertChannel(channel, 1, 3.1021, 3.1021, 4.0982, 4.0982);
126+
AssertChannel(channel, 2, 3.7194, 3.7194, 4.9910, 4.9910);
127+
AssertChannel(channel, 3, 3.9968, 3.9968, 5.1224, 5.1224);
128+
AssertChannel(channel, 4, 7.8585, 7.8585, 10.1987, 10.1987);
129+
AssertChannel(channel, 5, 5.8103, 5.8103, 7.2667, 7.2667);
130+
AssertChannel(channel, 6, 8.7491, 8.7491, 10.7102, 10.7102);
131131
#endif
132132
}
133133

134-
private void TestChannel(IChannelPerceptualHash? channel, int index, double xyyHuPhashWithOpenCL, double xyyHuPhashWithoutOpenCL, double hsbHuPhashWithOpenCL, double hsbHuPhashWithoutOpenCL)
134+
private static void AssertChannel(IChannelPerceptualHash? channel, int channelIndex, double xyyHuPhashWithOpenCL, double xyyHuPhashWithoutOpenCL, double hsbHuPhashWithOpenCL, double hsbHuPhashWithoutOpenCL)
135135
{
136136
Assert.NotNull(channel);
137137

138-
OpenCLValue.Assert(xyyHuPhashWithOpenCL, xyyHuPhashWithoutOpenCL, channel.HuPhash(ColorSpace.XyY, index));
139-
OpenCLValue.Assert(hsbHuPhashWithOpenCL, hsbHuPhashWithoutOpenCL, channel.HuPhash(ColorSpace.HSB, index));
138+
OpenCLValue.Assert(xyyHuPhashWithOpenCL, xyyHuPhashWithoutOpenCL, channel.HuPhash(ColorSpace.XyY, channelIndex));
139+
OpenCLValue.Assert(hsbHuPhashWithOpenCL, hsbHuPhashWithoutOpenCL, channel.HuPhash(ColorSpace.HSB, channelIndex));
140140
}
141141
}
142142
}

0 commit comments

Comments
 (0)