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

Side by Side Diff: Source/platform/DecimalTest.cpp

Issue 281033002: Fix MaxCoefficient static variable value in Decimal.cpp (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: use lowercase x Created 6 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 | Annotate | Revision Log
« no previous file with comments | « Source/platform/Decimal.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 (C) 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2012 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 464 matching lines...) Expand 10 before | Expand all | Expand 10 after
475 EXPECT_DECIMAL_ENCODED_DATA_EQ(1u, 1023, Positive, encode(1, 1023, Positive) ); 475 EXPECT_DECIMAL_ENCODED_DATA_EQ(1u, 1023, Positive, encode(1, 1023, Positive) );
476 EXPECT_DECIMAL_ENCODED_DATA_EQ(1u, 1023, Negative, encode(1, 1023, Negative) ); 476 EXPECT_DECIMAL_ENCODED_DATA_EQ(1u, 1023, Negative, encode(1, 1023, Negative) );
477 EXPECT_TRUE(encode(1, 2000, Positive).isInfinity()); 477 EXPECT_TRUE(encode(1, 2000, Positive).isInfinity());
478 EXPECT_TRUE(encode(1, 2000, Negative).isInfinity()); 478 EXPECT_TRUE(encode(1, 2000, Negative).isInfinity());
479 EXPECT_DECIMAL_ENCODED_DATA_EQ(0u, 0, Positive, encode(1, -2000, Positive)); 479 EXPECT_DECIMAL_ENCODED_DATA_EQ(0u, 0, Positive, encode(1, -2000, Positive));
480 EXPECT_DECIMAL_ENCODED_DATA_EQ(0u, 0, Negative, encode(1, -2000, Negative)); 480 EXPECT_DECIMAL_ENCODED_DATA_EQ(0u, 0, Negative, encode(1, -2000, Negative));
481 EXPECT_DECIMAL_ENCODED_DATA_EQ(UINT64_C(99999999999999998), 0, Positive, enc ode(UINT64_C(99999999999999998), 0, Positive)); 481 EXPECT_DECIMAL_ENCODED_DATA_EQ(UINT64_C(99999999999999998), 0, Positive, enc ode(UINT64_C(99999999999999998), 0, Positive));
482 EXPECT_DECIMAL_ENCODED_DATA_EQ(UINT64_C(99999999999999998), 0, Negative, enc ode(UINT64_C(99999999999999998), 0, Negative)); 482 EXPECT_DECIMAL_ENCODED_DATA_EQ(UINT64_C(99999999999999998), 0, Negative, enc ode(UINT64_C(99999999999999998), 0, Negative));
483 EXPECT_DECIMAL_ENCODED_DATA_EQ(UINT64_C(99999999999999999), 0, Positive, enc ode(UINT64_C(99999999999999999), 0, Positive)); 483 EXPECT_DECIMAL_ENCODED_DATA_EQ(UINT64_C(99999999999999999), 0, Positive, enc ode(UINT64_C(99999999999999999), 0, Positive));
484 EXPECT_DECIMAL_ENCODED_DATA_EQ(UINT64_C(99999999999999999), 0, Negative, enc ode(UINT64_C(99999999999999999), 0, Negative)); 484 EXPECT_DECIMAL_ENCODED_DATA_EQ(UINT64_C(99999999999999999), 0, Negative, enc ode(UINT64_C(99999999999999999), 0, Negative));
485 EXPECT_DECIMAL_ENCODED_DATA_EQ(UINT64_C(10000000000000000), 1, Positive, enc ode(UINT64_C(100000000000000000), 0, Positive)); 485 EXPECT_DECIMAL_ENCODED_DATA_EQ(UINT64_C(100000000000000000), 0, Positive, en code(UINT64_C(100000000000000000), 0, Positive));
486 EXPECT_DECIMAL_ENCODED_DATA_EQ(UINT64_C(10000000000000000), 1, Negative, enc ode(UINT64_C(100000000000000000), 0, Negative)); 486 EXPECT_DECIMAL_ENCODED_DATA_EQ(UINT64_C(100000000000000000), 0, Negative, en code(UINT64_C(100000000000000000), 0, Negative));
487 } 487 }
488 488
489 TEST_F(DecimalTest, Division) 489 TEST_F(DecimalTest, Division)
490 { 490 {
491 EXPECT_EQ(encode(0, 0, Positive), Decimal(0) / Decimal(1)); 491 EXPECT_EQ(encode(0, 0, Positive), Decimal(0) / Decimal(1));
492 EXPECT_EQ(encode(2, 0, Negative), Decimal(2) / Decimal(-1)); 492 EXPECT_EQ(encode(2, 0, Negative), Decimal(2) / Decimal(-1));
493 EXPECT_EQ(encode(5, -1, Negative), Decimal(-1) / Decimal(2)); 493 EXPECT_EQ(encode(5, -1, Negative), Decimal(-1) / Decimal(2));
494 EXPECT_EQ(encode(99, 0, Positive), Decimal(99) / Decimal(1)); 494 EXPECT_EQ(encode(99, 0, Positive), Decimal(99) / Decimal(1));
495 EXPECT_EQ(Decimal(1), Decimal(-50) / Decimal(-50)); 495 EXPECT_EQ(Decimal(1), Decimal(-50) / Decimal(-50));
496 EXPECT_EQ(encode(UINT64_C(3333333333333333), -16, Positive), Decimal(1) / De cimal(3)); 496 EXPECT_EQ(encode(UINT64_C(33333333333333333), -17, Positive), Decimal(1) / D ecimal(3));
497 EXPECT_EQ(encode(UINT64_C(12345678901234), -1, Positive), encode(UINT64_C(12 345678901234), 0, Positive) / Decimal(10)); 497 EXPECT_EQ(encode(UINT64_C(12345678901234), -1, Positive), encode(UINT64_C(12 345678901234), 0, Positive) / Decimal(10));
498 } 498 }
499 499
500 TEST_F(DecimalTest, DivisionBigExponent) 500 TEST_F(DecimalTest, DivisionBigExponent)
501 { 501 {
502 EXPECT_EQ(encode(1, 1022, Positive), encode(1, 1022, Positive) / encode(1, 0 , Positive)); 502 EXPECT_EQ(encode(1, 1022, Positive), encode(1, 1022, Positive) / encode(1, 0 , Positive));
503 EXPECT_EQ(encode(1, 0, Positive), encode(1, 1022, Positive) / encode(1, 1022 , Positive)); 503 EXPECT_EQ(encode(1, 0, Positive), encode(1, 1022, Positive) / encode(1, 1022 , Positive));
504 EXPECT_EQ(Decimal::infinity(Positive), encode(1, 1022, Positive) / encode(1, -1000, Positive)); 504 EXPECT_EQ(Decimal::infinity(Positive), encode(1, 1022, Positive) / encode(1, -1000, Positive));
505 } 505 }
506 506
(...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after
913 TEST_F(DecimalTest, Remainder) 913 TEST_F(DecimalTest, Remainder)
914 { 914 {
915 EXPECT_EQ(encode(21, -1, Positive), encode(21, -1, Positive).remainder(3)); 915 EXPECT_EQ(encode(21, -1, Positive), encode(21, -1, Positive).remainder(3));
916 EXPECT_EQ(Decimal(1), Decimal(10).remainder(3)); 916 EXPECT_EQ(Decimal(1), Decimal(10).remainder(3));
917 EXPECT_EQ(Decimal(1), Decimal(10).remainder(-3)); 917 EXPECT_EQ(Decimal(1), Decimal(10).remainder(-3));
918 EXPECT_EQ(encode(1, 0, Negative), Decimal(-10).remainder(3)); 918 EXPECT_EQ(encode(1, 0, Negative), Decimal(-10).remainder(3));
919 EXPECT_EQ(Decimal(-1), Decimal(-10).remainder(-3)); 919 EXPECT_EQ(Decimal(-1), Decimal(-10).remainder(-3));
920 EXPECT_EQ(encode(2, -1, Positive), encode(102, -1, Positive).remainder(1)); 920 EXPECT_EQ(encode(2, -1, Positive), encode(102, -1, Positive).remainder(1));
921 EXPECT_EQ(encode(1, -1, Positive), Decimal(10).remainder(encode(3, -1, Posit ive))); 921 EXPECT_EQ(encode(1, -1, Positive), Decimal(10).remainder(encode(3, -1, Posit ive)));
922 EXPECT_EQ(Decimal(1), encode(36, -1, Positive).remainder(encode(13, -1, Posi tive))); 922 EXPECT_EQ(Decimal(1), encode(36, -1, Positive).remainder(encode(13, -1, Posi tive)));
923 EXPECT_EQ(encode(1, 87, Positive), (encode(1234, 100, Positive).remainder(De cimal(3)))); 923 EXPECT_EQ(encode(1, 86, Positive), (encode(1234, 100, Positive).remainder(De cimal(3))));
924 EXPECT_EQ(Decimal(500), (Decimal(500).remainder(1000))); 924 EXPECT_EQ(Decimal(500), (Decimal(500).remainder(1000)));
925 EXPECT_EQ(Decimal(-500), (Decimal(-500).remainder(1000))); 925 EXPECT_EQ(Decimal(-500), (Decimal(-500).remainder(1000)));
926 } 926 }
927 927
928 TEST_F(DecimalTest, RemainderBigExponent) 928 TEST_F(DecimalTest, RemainderBigExponent)
929 { 929 {
930 EXPECT_EQ(encode(0, 1022, Positive), encode(1, 1022, Positive).remainder(enc ode(1, 0, Positive))); 930 EXPECT_EQ(encode(0, 1022, Positive), encode(1, 1022, Positive).remainder(enc ode(1, 0, Positive)));
931 EXPECT_EQ(encode(0, 1022, Positive), encode(1, 1022, Positive).remainder(enc ode(1, 1022, Positive))); 931 EXPECT_EQ(encode(0, 1022, Positive), encode(1, 1022, Positive).remainder(enc ode(1, 1022, Positive)));
932 EXPECT_EQ(Decimal::infinity(Positive), encode(1, 1022, Positive).remainder(e ncode(1, -1000, Positive))); 932 EXPECT_EQ(Decimal::infinity(Positive), encode(1, 1022, Positive).remainder(e ncode(1, -1000, Positive)));
933 } 933 }
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
1114 EXPECT_DECIMAL_STREQ("0.001", encode(UINT64_C(99999999999999999), -20, Posit ive)); 1114 EXPECT_DECIMAL_STREQ("0.001", encode(UINT64_C(99999999999999999), -20, Posit ive));
1115 EXPECT_DECIMAL_STREQ("1e-83", encode(UINT64_C(99999999999999999), -100, Posi tive)); 1115 EXPECT_DECIMAL_STREQ("1e-83", encode(UINT64_C(99999999999999999), -100, Posi tive));
1116 } 1116 }
1117 1117
1118 TEST_F(DecimalTest, ToStringSpecialValues) 1118 TEST_F(DecimalTest, ToStringSpecialValues)
1119 { 1119 {
1120 EXPECT_DECIMAL_STREQ("Infinity", Decimal::infinity(Positive)); 1120 EXPECT_DECIMAL_STREQ("Infinity", Decimal::infinity(Positive));
1121 EXPECT_DECIMAL_STREQ("-Infinity", Decimal::infinity(Negative)); 1121 EXPECT_DECIMAL_STREQ("-Infinity", Decimal::infinity(Negative));
1122 EXPECT_DECIMAL_STREQ("NaN", Decimal::nan()); 1122 EXPECT_DECIMAL_STREQ("NaN", Decimal::nan());
1123 } 1123 }
OLDNEW
« no previous file with comments | « Source/platform/Decimal.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698