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

Side by Side Diff: tests/MathTest.cpp

Issue 1952303005: Remove Sk(Float|Double)PinToFixed functions, only used in tests. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 7 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
« no previous file with comments | « include/private/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 "float.h" 8 #include "float.h"
9 9
10 #include "SkColorPriv.h" 10 #include "SkColorPriv.h"
(...skipping 681 matching lines...) Expand 10 before | Expand all | Expand 10 after
692 test_divmod<int16_t>(r); 692 test_divmod<int16_t>(r);
693 } 693 }
694 694
695 DEF_TEST(divmod_s32, r) { 695 DEF_TEST(divmod_s32, r) {
696 test_divmod<int32_t>(r); 696 test_divmod<int32_t>(r);
697 } 697 }
698 698
699 DEF_TEST(divmod_s64, r) { 699 DEF_TEST(divmod_s64, r) {
700 test_divmod<int64_t>(r); 700 test_divmod<int64_t>(r);
701 } 701 }
702
703 DEF_TEST(PinToFixed, reporter) {
704 // double
705 REPORTER_ASSERT(reporter, 0 == SkDoublePinToFixed(0.0));
706 REPORTER_ASSERT(reporter, 0x10000 == SkDoublePinToFixed(1.0));
707 REPORTER_ASSERT(reporter, 0x7FFFFFFE == SkDoublePinToFixed(32767.999984741)) ;
708 REPORTER_ASSERT(reporter, 0x7FFFFFFF == SkDoublePinToFixed(32767.999984742)) ;
709 REPORTER_ASSERT(reporter, 0x7FFFFFFF == SkDoublePinToFixed(32767.999999999)) ;
710 REPORTER_ASSERT(reporter, 0x7FFFFFFF == SkDoublePinToFixed(32768.0));
711 REPORTER_ASSERT(reporter, 0x7FFFFFFF == SkDoublePinToFixed(5e10));
712 REPORTER_ASSERT(reporter, 0x7FFFFFFF == SkDoublePinToFixed(DBL_MAX));
713 REPORTER_ASSERT(reporter, -0x10000 == SkDoublePinToFixed(-1.0));
714 // SK_FixedMin is defined to be -SK_FixedMax.
715 REPORTER_ASSERT(reporter, -0x7FFFFFFE == SkDoublePinToFixed(-32767.999984741 ));
716 REPORTER_ASSERT(reporter, -0x7FFFFFFF == SkDoublePinToFixed(-32767.999984742 ));
717 REPORTER_ASSERT(reporter, -0x7FFFFFFF == SkDoublePinToFixed(-32767.999999999 ));
718 REPORTER_ASSERT(reporter, -0x7FFFFFFF == SkDoublePinToFixed(-32768.0));
719 REPORTER_ASSERT(reporter, -0x7FFFFFFF == SkDoublePinToFixed(-5e10));
720 REPORTER_ASSERT(reporter, -0x7FFFFFFF == SkDoublePinToFixed(-DBL_MAX));
721
722 // float
723 REPORTER_ASSERT(reporter, 0 == SkFloatPinToFixed(0.0f));
724 REPORTER_ASSERT(reporter, 0x10000 == SkFloatPinToFixed(1.0f));
725 // SkFixed has more precision than float near SK_FixedMax, so SkFloatPinToFi xed will never
726 // produce output between 0x7FFFFF80 and 0x7FFFFFFF.
727 REPORTER_ASSERT(reporter, 0x7FFFFF80 == SkFloatPinToFixed(32767.9990f));
728 REPORTER_ASSERT(reporter, 0x7FFFFFFF == SkFloatPinToFixed(32767.9991f));
729 REPORTER_ASSERT(reporter, 0x7FFFFFFF == SkFloatPinToFixed(32768.0f));
730 REPORTER_ASSERT(reporter, 0x7FFFFFFF == SkFloatPinToFixed(5e10f));
731 REPORTER_ASSERT(reporter, 0x7FFFFFFF == SkFloatPinToFixed(FLT_MAX));
732 REPORTER_ASSERT(reporter, -0x10000 == SkFloatPinToFixed(-1.0f));
733 // SK_FixedMin is defined to be -SK_FixedMax.
734 REPORTER_ASSERT(reporter, -0x7FFFFF80 == SkFloatPinToFixed(-32767.9990f));
735 REPORTER_ASSERT(reporter, -0x7FFFFFFF == SkFloatPinToFixed(-32767.9991f));
736 REPORTER_ASSERT(reporter, -0x7FFFFFFF == SkFloatPinToFixed(-32768.0f));
737 REPORTER_ASSERT(reporter, -0x7FFFFFFF == SkFloatPinToFixed(-5e10f));
738 REPORTER_ASSERT(reporter, -0x7FFFFFFF == SkFloatPinToFixed(-FLT_MAX));
739 }
OLDNEW
« no previous file with comments | « include/private/SkFixed.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698