| OLD | NEW |
| 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 19 matching lines...) Expand all Loading... |
| 30 | 30 |
| 31 #include "platform/Decimal.h" | 31 #include "platform/Decimal.h" |
| 32 | 32 |
| 33 #include "testing/gtest/include/gtest/gtest.h" | 33 #include "testing/gtest/include/gtest/gtest.h" |
| 34 #include "wtf/MathExtras.h" | 34 #include "wtf/MathExtras.h" |
| 35 #include "wtf/text/CString.h" | 35 #include "wtf/text/CString.h" |
| 36 #include <float.h> | 36 #include <float.h> |
| 37 | 37 |
| 38 namespace blink { | 38 namespace blink { |
| 39 | 39 |
| 40 std::ostream& operator<<(std::ostream& os, const Decimal& decimal) | 40 // Simulate core/html/forms/StepRange |
| 41 { | |
| 42 Decimal::EncodedData data = decimal.value(); | |
| 43 return os | |
| 44 << "encode(" << String::number(data.coefficient()).ascii().data() | |
| 45 << ", " << String::number(data.exponent()).ascii().data() | |
| 46 << ", " << (data.getSign() == Decimal::Negative ? "Negative" : "Positive
") | |
| 47 << ")=" << decimal.toString().ascii().data(); | |
| 48 } | |
| 49 | |
| 50 // Simulate WebCore/html/StepRange | |
| 51 class DecimalStepRange { | 41 class DecimalStepRange { |
| 52 public: | 42 public: |
| 53 Decimal maximum; | 43 Decimal maximum; |
| 54 Decimal minimum; | 44 Decimal minimum; |
| 55 Decimal step; | 45 Decimal step; |
| 56 | 46 |
| 57 DecimalStepRange(const Decimal& minimum, const Decimal& maximum, const Decim
al& step) | 47 DecimalStepRange(const Decimal& minimum, const Decimal& maximum, const Decim
al& step) |
| 58 : maximum(maximum) | 48 : maximum(maximum) |
| 59 , minimum(minimum) | 49 , minimum(minimum) |
| 60 , step(step) | 50 , step(step) |
| (...skipping 1055 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1116 } | 1106 } |
| 1117 | 1107 |
| 1118 TEST_F(DecimalTest, ToStringSpecialValues) | 1108 TEST_F(DecimalTest, ToStringSpecialValues) |
| 1119 { | 1109 { |
| 1120 EXPECT_DECIMAL_STREQ("Infinity", Decimal::infinity(Positive)); | 1110 EXPECT_DECIMAL_STREQ("Infinity", Decimal::infinity(Positive)); |
| 1121 EXPECT_DECIMAL_STREQ("-Infinity", Decimal::infinity(Negative)); | 1111 EXPECT_DECIMAL_STREQ("-Infinity", Decimal::infinity(Negative)); |
| 1122 EXPECT_DECIMAL_STREQ("NaN", Decimal::nan()); | 1112 EXPECT_DECIMAL_STREQ("NaN", Decimal::nan()); |
| 1123 } | 1113 } |
| 1124 | 1114 |
| 1125 } // namespace blink | 1115 } // namespace blink |
| OLD | NEW |