1 /*
2 * Copyright 2015 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8 #include "Sk4px.h"
9 #include "SkNx.h"
10 #include "SkRandom.h"
11 #include "Test.h"
12
13 template <int N>
test_Nf(skiatest::Reporter * r)14 static void test_Nf(skiatest::Reporter* r) {
15
16 auto assert_nearly_eq = [&](float eps, const SkNx<N, float>& v,
17 float a, float b, float c, float d) {
18 auto close = [=](float a, float b) { return fabsf(a-b) <= eps; };
19 float vals[4];
20 v.store(vals);
21 bool ok = close(vals[0], a) && close(vals[1], b)
22 && close( v[0], a) && close( v[1], b);
23 REPORTER_ASSERT(r, ok);
24 if (N == 4) {
25 ok = close(vals[2], c) && close(vals[3], d)
26 && close( v[2], c) && close( v[3], d);
27 REPORTER_ASSERT(r, ok);
28 }
29 };
30 auto assert_eq = [&](const SkNx<N, float>& v, float a, float b, float c, float d) {
31 return assert_nearly_eq(0, v, a,b,c,d);
32 };
33
34 float vals[] = {3, 4, 5, 6};
35 SkNx<N,float> a = SkNx<N,float>::Load(vals),
36 b(a),
37 c = a;
38 SkNx<N,float> d;
39 d = a;
40
41 assert_eq(a, 3, 4, 5, 6);
42 assert_eq(b, 3, 4, 5, 6);
43 assert_eq(c, 3, 4, 5, 6);
44 assert_eq(d, 3, 4, 5, 6);
45
46 assert_eq(a+b, 6, 8, 10, 12);
47 assert_eq(a*b, 9, 16, 25, 36);
48 assert_eq(a*b-b, 6, 12, 20, 30);
49 assert_eq((a*b).sqrt(), 3, 4, 5, 6);
50 assert_eq(a/b, 1, 1, 1, 1);
51 assert_eq(SkNx<N,float>(0)-a, -3, -4, -5, -6);
52
53 SkNx<N,float> fours(4);
54
55 assert_eq(fours.sqrt(), 2,2,2,2);
56 assert_nearly_eq(0.001f, fours.rsqrt(), 0.5, 0.5, 0.5, 0.5);
57
58 assert_nearly_eq(0.001f, fours.invert(), 0.25, 0.25, 0.25, 0.25);
59
60 assert_eq(SkNx<N,float>::Min(a, fours), 3, 4, 4, 4);
61 assert_eq(SkNx<N,float>::Max(a, fours), 4, 4, 5, 6);
62
63 // Test some comparisons. This is not exhaustive.
64 REPORTER_ASSERT(r, (a == b).allTrue());
65 REPORTER_ASSERT(r, (a+b == a*b-b).anyTrue());
66 REPORTER_ASSERT(r, !(a+b == a*b-b).allTrue());
67 REPORTER_ASSERT(r, !(a+b == a*b).anyTrue());
68 REPORTER_ASSERT(r, !(a != b).anyTrue());
69 REPORTER_ASSERT(r, (a < fours).anyTrue());
70 REPORTER_ASSERT(r, (a <= fours).anyTrue());
71 REPORTER_ASSERT(r, !(a > fours).allTrue());
72 REPORTER_ASSERT(r, !(a >= fours).allTrue());
73 }
74
DEF_TEST(SkNf,r)75 DEF_TEST(SkNf, r) {
76 test_Nf<2>(r);
77 test_Nf<4>(r);
78 }
79
80 template <int N, typename T>
test_Ni(skiatest::Reporter * r)81 void test_Ni(skiatest::Reporter* r) {
82 auto assert_eq = [&](const SkNx<N,T>& v, T a, T b, T c, T d, T e, T f, T g, T h) {
83 T vals[8];
84 v.store(vals);
85
86 switch (N) {
87 case 8: REPORTER_ASSERT(r, vals[4] == e && vals[5] == f && vals[6] == g && vals[7] == h);
88 case 4: REPORTER_ASSERT(r, vals[2] == c && vals[3] == d);
89 case 2: REPORTER_ASSERT(r, vals[0] == a && vals[1] == b);
90 }
91 switch (N) {
92 case 8: REPORTER_ASSERT(r, v[4] == e && v[5] == f &&
93 v[6] == g && v[7] == h);
94 case 4: REPORTER_ASSERT(r, v[2] == c && v[3] == d);
95 case 2: REPORTER_ASSERT(r, v[0] == a && v[1] == b);
96 }
97 };
98
99 T vals[] = { 1,2,3,4,5,6,7,8 };
100 SkNx<N,T> a = SkNx<N,T>::Load(vals),
101 b(a),
102 c = a;
103 SkNx<N,T> d;
104 d = a;
105
106 assert_eq(a, 1,2,3,4,5,6,7,8);
107 assert_eq(b, 1,2,3,4,5,6,7,8);
108 assert_eq(c, 1,2,3,4,5,6,7,8);
109 assert_eq(d, 1,2,3,4,5,6,7,8);
110
111 assert_eq(a+a, 2,4,6,8,10,12,14,16);
112 assert_eq(a*a, 1,4,9,16,25,36,49,64);
113 assert_eq(a*a-a, 0,2,6,12,20,30,42,56);
114
115 assert_eq(a >> 2, 0,0,0,1,1,1,1,2);
116 assert_eq(a << 1, 2,4,6,8,10,12,14,16);
117
118 REPORTER_ASSERT(r, a[1] == 2);
119 }
120
DEF_TEST(SkNx,r)121 DEF_TEST(SkNx, r) {
122 test_Ni<2, uint16_t>(r);
123 test_Ni<4, uint16_t>(r);
124 test_Ni<8, uint16_t>(r);
125
126 test_Ni<2, int>(r);
127 test_Ni<4, int>(r);
128 test_Ni<8, int>(r);
129 }
130
DEF_TEST(SkNi_min_lt,r)131 DEF_TEST(SkNi_min_lt, r) {
132 // Exhaustively check the 8x8 bit space.
133 for (int a = 0; a < (1<<8); a++) {
134 for (int b = 0; b < (1<<8); b++) {
135 Sk16b aw(a), bw(b);
136 REPORTER_ASSERT(r, Sk16b::Min(aw, bw)[0] == SkTMin(a, b));
137 REPORTER_ASSERT(r, !(aw < bw)[0] == !(a < b));
138 }}
139
140 // Exhausting the 16x16 bit space is kind of slow, so only do that in release builds.
141 #ifdef SK_DEBUG
142 SkRandom rand;
143 for (int i = 0; i < (1<<16); i++) {
144 uint16_t a = rand.nextU() >> 16,
145 b = rand.nextU() >> 16;
146 REPORTER_ASSERT(r, Sk16h::Min(Sk16h(a), Sk16h(b))[0] == SkTMin(a, b));
147 }
148 #else
149 for (int a = 0; a < (1<<16); a++) {
150 for (int b = 0; b < (1<<16); b++) {
151 REPORTER_ASSERT(r, Sk16h::Min(Sk16h(a), Sk16h(b))[0] == SkTMin(a, b));
152 }}
153 #endif
154 }
155
DEF_TEST(SkNi_saturatedAdd,r)156 DEF_TEST(SkNi_saturatedAdd, r) {
157 for (int a = 0; a < (1<<8); a++) {
158 for (int b = 0; b < (1<<8); b++) {
159 int exact = a+b;
160 if (exact > 255) { exact = 255; }
161 if (exact < 0) { exact = 0; }
162
163 REPORTER_ASSERT(r, Sk16b(a).saturatedAdd(Sk16b(b))[0] == exact);
164 }
165 }
166 }
167
DEF_TEST(SkNi_mulHi,r)168 DEF_TEST(SkNi_mulHi, r) {
169 // First 8 primes.
170 Sk4u a{ 0x00020000, 0x00030000, 0x00050000, 0x00070000 };
171 Sk4u b{ 0x000b0000, 0x000d0000, 0x00110000, 0x00130000 };
172
173 Sk4u q{22, 39, 85, 133};
174
175 Sk4u c = a.mulHi(b);
176 REPORTER_ASSERT(r, c[0] == q[0]);
177 REPORTER_ASSERT(r, c[1] == q[1]);
178 REPORTER_ASSERT(r, c[2] == q[2]);
179 REPORTER_ASSERT(r, c[3] == q[3]);
180 }
181
DEF_TEST(Sk4px_muldiv255round,r)182 DEF_TEST(Sk4px_muldiv255round, r) {
183 for (int a = 0; a < (1<<8); a++) {
184 for (int b = 0; b < (1<<8); b++) {
185 int exact = (a*b+127)/255;
186
187 // Duplicate a and b 16x each.
188 Sk4px av = Sk16b(a),
189 bv = Sk16b(b);
190
191 // This way should always be exactly correct.
192 int correct = (av * bv).div255()[0];
193 REPORTER_ASSERT(r, correct == exact);
194
195 // We're a bit more flexible on this method: correct for 0 or 255, otherwise off by <=1.
196 int fast = av.approxMulDiv255(bv)[0];
197 REPORTER_ASSERT(r, fast-exact >= -1 && fast-exact <= 1);
198 if (a == 0 || a == 255 || b == 0 || b == 255) {
199 REPORTER_ASSERT(r, fast == exact);
200 }
201 }
202 }
203 }
204
DEF_TEST(SkNx_abs,r)205 DEF_TEST(SkNx_abs, r) {
206 auto fs = Sk4f(0.0f, -0.0f, 2.0f, -4.0f).abs();
207 REPORTER_ASSERT(r, fs[0] == 0.0f);
208 REPORTER_ASSERT(r, fs[1] == 0.0f);
209 REPORTER_ASSERT(r, fs[2] == 2.0f);
210 REPORTER_ASSERT(r, fs[3] == 4.0f);
211 auto fshi = Sk2f(0.0f, -0.0f).abs();
212 auto fslo = Sk2f(2.0f, -4.0f).abs();
213 REPORTER_ASSERT(r, fshi[0] == 0.0f);
214 REPORTER_ASSERT(r, fshi[1] == 0.0f);
215 REPORTER_ASSERT(r, fslo[0] == 2.0f);
216 REPORTER_ASSERT(r, fslo[1] == 4.0f);
217 }
218
DEF_TEST(Sk4i_abs,r)219 DEF_TEST(Sk4i_abs, r) {
220 auto is = Sk4i(0, -1, 2, -2147483647).abs();
221 REPORTER_ASSERT(r, is[0] == 0);
222 REPORTER_ASSERT(r, is[1] == 1);
223 REPORTER_ASSERT(r, is[2] == 2);
224 REPORTER_ASSERT(r, is[3] == 2147483647);
225 }
226
DEF_TEST(Sk4i_minmax,r)227 DEF_TEST(Sk4i_minmax, r) {
228 auto a = Sk4i(0, 2, 4, 6);
229 auto b = Sk4i(1, 1, 3, 7);
230 auto min = Sk4i::Min(a, b);
231 auto max = Sk4i::Max(a, b);
232 for(int i = 0; i < 4; ++i) {
233 REPORTER_ASSERT(r, min[i] == SkTMin(a[i], b[i]));
234 REPORTER_ASSERT(r, max[i] == SkTMax(a[i], b[i]));
235 }
236 }
237
DEF_TEST(SkNx_floor,r)238 DEF_TEST(SkNx_floor, r) {
239 auto fs = Sk4f(0.4f, -0.4f, 0.6f, -0.6f).floor();
240 REPORTER_ASSERT(r, fs[0] == 0.0f);
241 REPORTER_ASSERT(r, fs[1] == -1.0f);
242 REPORTER_ASSERT(r, fs[2] == 0.0f);
243 REPORTER_ASSERT(r, fs[3] == -1.0f);
244
245 auto fs2 = Sk2f(0.4f, -0.4f).floor();
246 REPORTER_ASSERT(r, fs2[0] == 0.0f);
247 REPORTER_ASSERT(r, fs2[1] == -1.0f);
248
249 auto fs3 = Sk2f(0.6f, -0.6f).floor();
250 REPORTER_ASSERT(r, fs3[0] == 0.0f);
251 REPORTER_ASSERT(r, fs3[1] == -1.0f);
252 }
253
DEF_TEST(SkNx_shuffle,r)254 DEF_TEST(SkNx_shuffle, r) {
255 Sk4f f4(0,10,20,30);
256
257 Sk2f f2 = SkNx_shuffle<2,1>(f4);
258 REPORTER_ASSERT(r, f2[0] == 20);
259 REPORTER_ASSERT(r, f2[1] == 10);
260
261 f4 = SkNx_shuffle<0,1,1,0>(f2);
262 REPORTER_ASSERT(r, f4[0] == 20);
263 REPORTER_ASSERT(r, f4[1] == 10);
264 REPORTER_ASSERT(r, f4[2] == 10);
265 REPORTER_ASSERT(r, f4[3] == 20);
266 }
267
DEF_TEST(SkNx_int_float,r)268 DEF_TEST(SkNx_int_float, r) {
269 Sk4f f(-2.3f, 1.0f, 0.45f, 0.6f);
270
271 Sk4i i = SkNx_cast<int>(f);
272 REPORTER_ASSERT(r, i[0] == -2);
273 REPORTER_ASSERT(r, i[1] == 1);
274 REPORTER_ASSERT(r, i[2] == 0);
275 REPORTER_ASSERT(r, i[3] == 0);
276
277 f = SkNx_cast<float>(i);
278 REPORTER_ASSERT(r, f[0] == -2.0f);
279 REPORTER_ASSERT(r, f[1] == 1.0f);
280 REPORTER_ASSERT(r, f[2] == 0.0f);
281 REPORTER_ASSERT(r, f[3] == 0.0f);
282 }
283
284 #include "SkRandom.h"
285
DEF_TEST(SkNx_u16_float,r)286 DEF_TEST(SkNx_u16_float, r) {
287 {
288 // u16 --> float
289 auto h4 = Sk4h(15, 17, 257, 65535);
290 auto f4 = SkNx_cast<float>(h4);
291 REPORTER_ASSERT(r, f4[0] == 15.0f);
292 REPORTER_ASSERT(r, f4[1] == 17.0f);
293 REPORTER_ASSERT(r, f4[2] == 257.0f);
294 REPORTER_ASSERT(r, f4[3] == 65535.0f);
295 }
296 {
297 // float -> u16
298 auto f4 = Sk4f(15, 17, 257, 65535);
299 auto h4 = SkNx_cast<uint16_t>(f4);
300 REPORTER_ASSERT(r, h4[0] == 15);
301 REPORTER_ASSERT(r, h4[1] == 17);
302 REPORTER_ASSERT(r, h4[2] == 257);
303 REPORTER_ASSERT(r, h4[3] == 65535);
304 }
305
306 // starting with any u16 value, we should be able to have a perfect round-trip in/out of floats
307 //
308 SkRandom rand;
309 for (int i = 0; i < 10000; ++i) {
310 const uint16_t s16[4] {
311 (uint16_t)(rand.nextU() >> 16), (uint16_t)(rand.nextU() >> 16),
312 (uint16_t)(rand.nextU() >> 16), (uint16_t)(rand.nextU() >> 16),
313 };
314 auto u4_0 = Sk4h::Load(s16);
315 auto f4 = SkNx_cast<float>(u4_0);
316 auto u4_1 = SkNx_cast<uint16_t>(f4);
317 uint16_t d16[4];
318 u4_1.store(d16);
319 REPORTER_ASSERT(r, !memcmp(s16, d16, sizeof(s16)));
320 }
321 }
322
323 // The SSE2 implementation of SkNx_cast<uint16_t>(Sk4i) is non-trivial, so worth a test.
DEF_TEST(SkNx_int_u16,r)324 DEF_TEST(SkNx_int_u16, r) {
325 // These are pretty hard to get wrong.
326 for (int i = 0; i <= 0x7fff; i++) {
327 uint16_t expected = (uint16_t)i;
328 uint16_t actual = SkNx_cast<uint16_t>(Sk4i(i))[0];
329
330 REPORTER_ASSERT(r, expected == actual);
331 }
332
333 // A naive implementation with _mm_packs_epi32 would succeed up to 0x7fff but fail here:
334 for (int i = 0x8000; (1) && i <= 0xffff; i++) {
335 uint16_t expected = (uint16_t)i;
336 uint16_t actual = SkNx_cast<uint16_t>(Sk4i(i))[0];
337
338 REPORTER_ASSERT(r, expected == actual);
339 }
340 }
341
DEF_TEST(SkNx_4fLoad4Store4,r)342 DEF_TEST(SkNx_4fLoad4Store4, r) {
343 float src[] = {
344 0.0f, 1.0f, 2.0f, 3.0f,
345 4.0f, 5.0f, 6.0f, 7.0f,
346 8.0f, 9.0f, 10.0f, 11.0f,
347 12.0f, 13.0f, 14.0f, 15.0f
348 };
349
350 Sk4f a, b, c, d;
351 Sk4f::Load4(src, &a, &b, &c, &d);
352 REPORTER_ASSERT(r, 0.0f == a[0]);
353 REPORTER_ASSERT(r, 4.0f == a[1]);
354 REPORTER_ASSERT(r, 8.0f == a[2]);
355 REPORTER_ASSERT(r, 12.0f == a[3]);
356 REPORTER_ASSERT(r, 1.0f == b[0]);
357 REPORTER_ASSERT(r, 5.0f == b[1]);
358 REPORTER_ASSERT(r, 9.0f == b[2]);
359 REPORTER_ASSERT(r, 13.0f == b[3]);
360 REPORTER_ASSERT(r, 2.0f == c[0]);
361 REPORTER_ASSERT(r, 6.0f == c[1]);
362 REPORTER_ASSERT(r, 10.0f == c[2]);
363 REPORTER_ASSERT(r, 14.0f == c[3]);
364 REPORTER_ASSERT(r, 3.0f == d[0]);
365 REPORTER_ASSERT(r, 7.0f == d[1]);
366 REPORTER_ASSERT(r, 11.0f == d[2]);
367 REPORTER_ASSERT(r, 15.0f == d[3]);
368
369 float dst[16];
370 Sk4f::Store4(dst, a, b, c, d);
371 REPORTER_ASSERT(r, 0 == memcmp(dst, src, 16 * sizeof(float)));
372 }
373
DEF_TEST(SkNx_neg,r)374 DEF_TEST(SkNx_neg, r) {
375 auto fs = -Sk4f(0.0f, -0.0f, 2.0f, -4.0f);
376 REPORTER_ASSERT(r, fs[0] == 0.0f);
377 REPORTER_ASSERT(r, fs[1] == 0.0f);
378 REPORTER_ASSERT(r, fs[2] == -2.0f);
379 REPORTER_ASSERT(r, fs[3] == 4.0f);
380 auto fshi = -Sk2f(0.0f, -0.0f);
381 auto fslo = -Sk2f(2.0f, -4.0f);
382 REPORTER_ASSERT(r, fshi[0] == 0.0f);
383 REPORTER_ASSERT(r, fshi[1] == 0.0f);
384 REPORTER_ASSERT(r, fslo[0] == -2.0f);
385 REPORTER_ASSERT(r, fslo[1] == 4.0f);
386 }
387
DEF_TEST(SkNx_thenElse,r)388 DEF_TEST(SkNx_thenElse, r) {
389 auto fs = (Sk4f(0.0f, -0.0f, 2.0f, -4.0f) < 0).thenElse(-1, 1);
390 REPORTER_ASSERT(r, fs[0] == 1);
391 REPORTER_ASSERT(r, fs[1] == 1);
392 REPORTER_ASSERT(r, fs[2] == 1);
393 REPORTER_ASSERT(r, fs[3] == -1);
394 auto fshi = (Sk2f(0.0f, -0.0f) < 0).thenElse(-1, 1);
395 auto fslo = (Sk2f(2.0f, -4.0f) < 0).thenElse(-1, 1);
396 REPORTER_ASSERT(r, fshi[0] == 1);
397 REPORTER_ASSERT(r, fshi[1] == 1);
398 REPORTER_ASSERT(r, fslo[0] == 1);
399 REPORTER_ASSERT(r, fslo[1] == -1);
400 }
401
DEF_TEST(Sk4f_Load2,r)402 DEF_TEST(Sk4f_Load2, r) {
403 float xy[8] = { 0,1,2,3,4,5,6,7 };
404
405 Sk4f x,y;
406 Sk4f::Load2(xy, &x,&y);
407
408 REPORTER_ASSERT(r, x[0] == 0);
409 REPORTER_ASSERT(r, x[1] == 2);
410 REPORTER_ASSERT(r, x[2] == 4);
411 REPORTER_ASSERT(r, x[3] == 6);
412
413 REPORTER_ASSERT(r, y[0] == 1);
414 REPORTER_ASSERT(r, y[1] == 3);
415 REPORTER_ASSERT(r, y[2] == 5);
416 REPORTER_ASSERT(r, y[3] == 7);
417 }
418
DEF_TEST(Sk2f_Load2,r)419 DEF_TEST(Sk2f_Load2, r) {
420 float xy[4] = { 0,1,2,3 };
421
422 Sk2f x,y;
423 Sk2f::Load2(xy, &x,&y);
424
425 REPORTER_ASSERT(r, x[0] == 0);
426 REPORTER_ASSERT(r, x[1] == 2);
427
428 REPORTER_ASSERT(r, y[0] == 1);
429 REPORTER_ASSERT(r, y[1] == 3);
430 }
431
DEF_TEST(Sk2f_Store2,r)432 DEF_TEST(Sk2f_Store2, r) {
433 Sk2f p0{0, 2};
434 Sk2f p1{1, 3};
435 float dst[4];
436 Sk2f::Store2(dst, p0, p1);
437 REPORTER_ASSERT(r, dst[0] == 0);
438 REPORTER_ASSERT(r, dst[1] == 1);
439 REPORTER_ASSERT(r, dst[2] == 2);
440 REPORTER_ASSERT(r, dst[3] == 3);
441 }
442
DEF_TEST(Sk2f_Store3,r)443 DEF_TEST(Sk2f_Store3, r) {
444 Sk2f p0{0, 3};
445 Sk2f p1{1, 4};
446 Sk2f p2{2, 5};
447 float dst[6];
448 Sk2f::Store3(dst, p0, p1, p2);
449 REPORTER_ASSERT(r, dst[0] == 0);
450 REPORTER_ASSERT(r, dst[1] == 1);
451 REPORTER_ASSERT(r, dst[2] == 2);
452 REPORTER_ASSERT(r, dst[3] == 3);
453 REPORTER_ASSERT(r, dst[4] == 4);
454 REPORTER_ASSERT(r, dst[5] == 5);
455 }
456
DEF_TEST(Sk2f_Store4,r)457 DEF_TEST(Sk2f_Store4, r) {
458 Sk2f p0{0, 4};
459 Sk2f p1{1, 5};
460 Sk2f p2{2, 6};
461 Sk2f p3{3, 7};
462
463 float dst[8] = {-1, -1, -1, -1, -1, -1, -1, -1};
464 Sk2f::Store4(dst, p0, p1, p2, p3);
465 REPORTER_ASSERT(r, dst[0] == 0);
466 REPORTER_ASSERT(r, dst[1] == 1);
467 REPORTER_ASSERT(r, dst[2] == 2);
468 REPORTER_ASSERT(r, dst[3] == 3);
469 REPORTER_ASSERT(r, dst[4] == 4);
470 REPORTER_ASSERT(r, dst[5] == 5);
471 REPORTER_ASSERT(r, dst[6] == 6);
472 REPORTER_ASSERT(r, dst[7] == 7);
473
474 // Ensure transposing to Sk4f works.
475 Sk4f dst4f[2] = {{-1, -1, -1, -1}, {-1, -1, -1, -1}};
476 Sk2f::Store4(dst4f, p0, p1, p2, p3);
477 REPORTER_ASSERT(r, dst4f[0][0] == 0);
478 REPORTER_ASSERT(r, dst4f[0][1] == 1);
479 REPORTER_ASSERT(r, dst4f[0][2] == 2);
480 REPORTER_ASSERT(r, dst4f[0][3] == 3);
481 REPORTER_ASSERT(r, dst4f[1][0] == 4);
482 REPORTER_ASSERT(r, dst4f[1][1] == 5);
483 REPORTER_ASSERT(r, dst4f[1][2] == 6);
484 REPORTER_ASSERT(r, dst4f[1][3] == 7);
485
486 }
487
DEF_TEST(Sk4f_minmax,r)488 DEF_TEST(Sk4f_minmax, r) {
489 REPORTER_ASSERT(r, 3 == Sk4f(0,1,2,3).max());
490 REPORTER_ASSERT(r, 2 == Sk4f(1,-5,2,-1).max());
491 REPORTER_ASSERT(r, -1 == Sk4f(-2,-1,-6,-3).max());
492 REPORTER_ASSERT(r, 3 == Sk4f(3,2,1,0).max());
493
494 REPORTER_ASSERT(r, 0 == Sk4f(0,1,2,3).min());
495 REPORTER_ASSERT(r, -5 == Sk4f(1,-5,2,-1).min());
496 REPORTER_ASSERT(r, -6 == Sk4f(-2,-1,-6,-3).min());
497 REPORTER_ASSERT(r, 0 == Sk4f(3,2,1,0).min());
498 }
499
DEF_TEST(SkNf_anyTrue_allTrue,r)500 DEF_TEST(SkNf_anyTrue_allTrue, r) {
501 REPORTER_ASSERT(r, (Sk2f{1,2} < Sk2f{3,4}).anyTrue());
502 REPORTER_ASSERT(r, (Sk2f{1,2} < Sk2f{3,4}).allTrue());
503 REPORTER_ASSERT(r, (Sk2f{3,2} < Sk2f{1,4}).anyTrue());
504 REPORTER_ASSERT(r, !(Sk2f{3,2} < Sk2f{1,4}).allTrue());
505 REPORTER_ASSERT(r, !(Sk2f{3,4} < Sk2f{1,2}).anyTrue());
506
507 REPORTER_ASSERT(r, (Sk4f{1,2,3,4} < Sk4f{3,4,5,6}).anyTrue());
508 REPORTER_ASSERT(r, (Sk4f{1,2,3,4} < Sk4f{3,4,5,6}).allTrue());
509 REPORTER_ASSERT(r, (Sk4f{1,2,3,4} < Sk4f{1,4,1,1}).anyTrue());
510 REPORTER_ASSERT(r, !(Sk4f{1,2,3,4} < Sk4f{1,4,1,1}).allTrue());
511 REPORTER_ASSERT(r, !(Sk4f{3,4,5,6} < Sk4f{1,2,3,4}).anyTrue());
512 }
513