OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2016 Google Inc. | 2 * Copyright 2016 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #include "Fuzz.h" | 8 #include "Fuzz.h" |
| 9 #include <stdlib.h> |
9 | 10 |
10 // This really is just an example Fuzz*.cpp file. | 11 // This really is just an example Fuzz*.cpp file. |
11 // It tests that two different ways of calculating the Paeth predictor function
are equivalent. | 12 // It tests that two different ways of calculating the Paeth predictor function
are equivalent. |
12 | 13 |
13 static uint8_t paeth_std(uint8_t a, uint8_t b, uint8_t c) { | 14 static uint8_t paeth_std(uint8_t a, uint8_t b, uint8_t c) { |
14 int p = a+b-c; | 15 int p = a+b-c; |
15 | 16 |
16 int pa = abs(p-a), | 17 int pa = abs(p-a), |
17 pb = abs(p-b), | 18 pb = abs(p-b), |
18 pc = abs(p-c); | 19 pc = abs(p-c); |
(...skipping 10 matching lines...) Expand all Loading... |
29 | 30 |
30 if (c <= min+delta) return max; | 31 if (c <= min+delta) return max; |
31 if (c >= max-delta) return min; | 32 if (c >= max-delta) return min; |
32 return c; | 33 return c; |
33 } | 34 } |
34 | 35 |
35 DEF_FUZZ(Paeth, fuzz) { | 36 DEF_FUZZ(Paeth, fuzz) { |
36 auto a = fuzz->nextB(), | 37 auto a = fuzz->nextB(), |
37 b = fuzz->nextB(), | 38 b = fuzz->nextB(), |
38 c = fuzz->nextB(); | 39 c = fuzz->nextB(); |
39 ASSERT(paeth_alt(a,b,c) == paeth_std(a,b,c)); | 40 SkDebugf("Paeth(%d,%d,%d)\n", a,b,c); |
| 41 |
| 42 if (a == b && b == c) { |
| 43 fuzz->signalBoring(); // Not really boring, just demoing signalBoring()
. |
| 44 } |
| 45 |
| 46 if (paeth_alt(a,b,c) != paeth_std(a,b,c)) { |
| 47 fuzz->signalBug(); |
| 48 } |
40 } | 49 } |
OLD | NEW |