Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(131)

Side by Side Diff: tests/ClampRangeTest.cpp

Issue 1439483002: Fix code that left shifts a negative value. This has undefined behavior. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Add comment about unsigned cast. Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « include/core/SkFixed.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2011 Google Inc. 2 * Copyright 2011 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 "SkRandom.h" 8 #include "SkRandom.h"
9 #include "Test.h" 9 #include "Test.h"
10 #include "gradients/SkClampRange.h" 10 #include "gradients/SkClampRange.h"
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 test_range( ff(2), 0, 20); 75 test_range( ff(2), 0, 20);
76 76
77 test_range(-10, 1, 20); 77 test_range(-10, 1, 20);
78 test_range(10, -1, 20); 78 test_range(10, -1, 20);
79 test_range(-10, 3, 20); 79 test_range(-10, 3, 20);
80 test_range(10, -3, 20); 80 test_range(10, -3, 20);
81 81
82 test_range(ff(1), ff(16384), 100); 82 test_range(ff(1), ff(16384), 100);
83 test_range(ff(-1), ff(-16384), 100); 83 test_range(ff(-1), ff(-16384), 100);
84 test_range(ff(1)/2, ff(16384), 100); 84 test_range(ff(1)/2, ff(16384), 100);
85 // TODO(reed): skia:2481, fix whatever bug this is, then uncomment 85 test_range(ff(1)/2, ff(-16384), 100);
86 //test_range(ff(1)/2, ff(-16384), 100);
87 86
88 SkRandom rand; 87 SkRandom rand;
89 88
90 // test non-overflow cases 89 // test non-overflow cases
91 for (int i = 0; i < 1000000; i++) { 90 for (int i = 0; i < 1000000; i++) {
92 SkFixed fx = rand.nextS() >> 1; 91 SkFixed fx = rand.nextS() >> 1;
93 SkFixed sx = rand.nextS() >> 1; 92 SkFixed sx = rand.nextS() >> 1;
94 int count = rand.nextU() % 1000 + 1; 93 int count = rand.nextU() % 1000 + 1;
95 SkFixed dx = (sx - fx) / count; 94 SkFixed dx = (sx - fx) / count;
96 test_range(fx, dx, count); 95 test_range(fx, dx, count);
97 } 96 }
98 97
99 // TODO(reed): skia:2481, fix whatever bug this is, then uncomment 98 // TODO(reed): skia:2481, fix whatever bug this is, then uncomment
100 /* 99 /*
101 // test overflow cases 100 // test overflow cases
102 for (int i = 0; i < 100000; i++) { 101 for (int i = 0; i < 100000; i++) {
103 SkFixed fx = rand.nextS(); 102 SkFixed fx = rand.nextS();
104 SkFixed dx = rand.nextS(); 103 SkFixed dx = rand.nextS();
105 int count = rand.nextU() % 1000 + 1; 104 int count = rand.nextU() % 1000 + 1;
106 test_range(fx, dx, count); 105 test_range(fx, dx, count);
107 } 106 }
108 */ 107 */
109 } 108 }
OLDNEW
« no previous file with comments | « include/core/SkFixed.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698