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

Side by Side Diff: tests/Sk64Test.cpp

Issue 122293002: Revert "Revert of https://codereview.chromium.org/113823003/" (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 6 years, 11 months 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 | Annotate | Revision Log
« no previous file with comments | « tests/BitmapCopyTest.cpp ('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 "Test.h" 8 #include "Test.h"
9 #include "TestClassDef.h" 9 #include "TestClassDef.h"
10 #include "Sk64.h"
10 #include "SkRandom.h" 11 #include "SkRandom.h"
11 #include <math.h> 12 #include <math.h>
12 13
13 struct BoolTable { 14 struct BoolTable {
14 int8_t zero, pos, neg, toBool, sign; 15 int8_t zero, pos, neg, toBool, sign;
15 }; 16 };
16 17
17 static void bool_table_test(skiatest::Reporter* reporter, 18 static void bool_table_test(skiatest::Reporter* reporter,
18 const Sk64& a, const BoolTable& table) 19 const Sk64& a, const BoolTable& table)
19 { 20 {
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 REPORTER_ASSERT(reporter, c.get32() == aa + bb); 86 REPORTER_ASSERT(reporter, c.get32() == aa + bb);
86 c = a; c.add(-bb); 87 c = a; c.add(-bb);
87 REPORTER_ASSERT(reporter, c.get32() == aa - bb); 88 REPORTER_ASSERT(reporter, c.get32() == aa - bb);
88 c = a; c.add(b); 89 c = a; c.add(b);
89 REPORTER_ASSERT(reporter, c.get32() == aa + bb); 90 REPORTER_ASSERT(reporter, c.get32() == aa + bb);
90 c = a; c.sub(b); 91 c = a; c.sub(b);
91 REPORTER_ASSERT(reporter, c.get32() == aa - bb); 92 REPORTER_ASSERT(reporter, c.get32() == aa - bb);
92 } 93 }
93 94
94 for (i = 0; i < 1000; i++) { 95 for (i = 0; i < 1000; i++) {
95 rand.next64(&a); //a.fHi >>= 1; // avoid overflow 96 a.set64(rand.next64());
96 rand.next64(&b); //b.fHi >>= 1; // avoid overflow 97 b.set64(rand.next64());
97 98
98 if (!(i & 3)) // want to explicitly test these cases 99 if (!(i & 3)) // want to explicitly test these cases
99 { 100 {
100 a.fLo = 0; 101 a.fLo = 0;
101 b.fLo = 0; 102 b.fLo = 0;
102 } 103 }
103 else if (!(i & 7)) // want to explicitly test these cases 104 else if (!(i & 7)) // want to explicitly test these cases
104 { 105 {
105 a.fHi = 0; 106 a.fHi = 0;
106 b.fHi = 0; 107 b.fHi = 0;
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 denom = wide.getSqrt(); 167 denom = wide.getSqrt();
167 int32_t ck = (int32_t)sqrt((double)wide.getLongLong()); 168 int32_t ck = (int32_t)sqrt((double)wide.getLongLong());
168 int diff = denom - ck; 169 int diff = denom - ck;
169 REPORTER_ASSERT(reporter, SkAbs32(diff) <= 1); 170 REPORTER_ASSERT(reporter, SkAbs32(diff) <= 1);
170 } 171 }
171 } 172 }
172 173
173 DEF_TEST(Sk64Test, reporter) { 174 DEF_TEST(Sk64Test, reporter) {
174 Sk64::UnitTestWithReporter(reporter); 175 Sk64::UnitTestWithReporter(reporter);
175 } 176 }
OLDNEW
« no previous file with comments | « tests/BitmapCopyTest.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698