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

Side by Side Diff: tests/MathTest.cpp

Issue 1503423003: ubsan shift fixes (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: add cast to work around win compiler Created 5 years 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 | « src/utils/SkDashPath.cpp ('k') | tests/RandomTest.cpp » ('j') | 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 "SkColorPriv.h" 8 #include "SkColorPriv.h"
9 #include "SkEndian.h" 9 #include "SkEndian.h"
10 #include "SkFloatBits.h" 10 #include "SkFloatBits.h"
(...skipping 543 matching lines...) Expand 10 before | Expand all | Expand 10 after
554 554
555 unittest_fastfloat(reporter); 555 unittest_fastfloat(reporter);
556 unittest_isfinite(reporter); 556 unittest_isfinite(reporter);
557 unittest_half(reporter); 557 unittest_half(reporter);
558 test_rsqrt(reporter); 558 test_rsqrt(reporter);
559 559
560 for (i = 0; i < 10000; i++) { 560 for (i = 0; i < 10000; i++) {
561 SkFixed numer = rand.nextS(); 561 SkFixed numer = rand.nextS();
562 SkFixed denom = rand.nextS(); 562 SkFixed denom = rand.nextS();
563 SkFixed result = SkFixedDiv(numer, denom); 563 SkFixed result = SkFixedDiv(numer, denom);
564 int64_t check = ((int64_t)numer << 16) / denom; 564 int64_t check = SkLeftShift((int64_t)numer, 16) / denom;
565 565
566 (void)SkCLZ(numer); 566 (void)SkCLZ(numer);
567 (void)SkCLZ(denom); 567 (void)SkCLZ(denom);
568 568
569 REPORTER_ASSERT(reporter, result != (SkFixed)SK_NaN32); 569 REPORTER_ASSERT(reporter, result != (SkFixed)SK_NaN32);
570 if (check > SK_MaxS32) { 570 if (check > SK_MaxS32) {
571 check = SK_MaxS32; 571 check = SK_MaxS32;
572 } else if (check < -SK_MaxS32) { 572 } else if (check < -SK_MaxS32) {
573 check = SK_MinS32; 573 check = SK_MinS32;
574 } 574 }
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
689 test_divmod<int16_t>(r); 689 test_divmod<int16_t>(r);
690 } 690 }
691 691
692 DEF_TEST(divmod_s32, r) { 692 DEF_TEST(divmod_s32, r) {
693 test_divmod<int32_t>(r); 693 test_divmod<int32_t>(r);
694 } 694 }
695 695
696 DEF_TEST(divmod_s64, r) { 696 DEF_TEST(divmod_s64, r) {
697 test_divmod<int64_t>(r); 697 test_divmod<int64_t>(r);
698 } 698 }
OLDNEW
« no previous file with comments | « src/utils/SkDashPath.cpp ('k') | tests/RandomTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698