| 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 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 210 EXPECT_EQ(NaN, NaN + NaN); | 210 EXPECT_EQ(NaN, NaN + NaN); |
| 211 EXPECT_EQ(NaN, NaN + Ten); | 211 EXPECT_EQ(NaN, NaN + Ten); |
| 212 EXPECT_EQ(NaN, Ten + NaN); | 212 EXPECT_EQ(NaN, Ten + NaN); |
| 213 | 213 |
| 214 EXPECT_EQ(NaN, NaN - Infinity); | 214 EXPECT_EQ(NaN, NaN - Infinity); |
| 215 EXPECT_EQ(NaN, NaN - MinusInfinity); | 215 EXPECT_EQ(NaN, NaN - MinusInfinity); |
| 216 EXPECT_EQ(NaN, Infinity - NaN); | 216 EXPECT_EQ(NaN, Infinity - NaN); |
| 217 EXPECT_EQ(NaN, MinusInfinity - NaN); | 217 EXPECT_EQ(NaN, MinusInfinity - NaN); |
| 218 } | 218 } |
| 219 | 219 |
| 220 TEST_F(DecimalTest, Ceiling) | 220 TEST_F(DecimalTest, Ceil) |
| 221 { | 221 { |
| 222 EXPECT_EQ(Decimal(1), Decimal(1).ceiling()); | 222 EXPECT_EQ(Decimal(1), Decimal(1).ceil()); |
| 223 EXPECT_EQ(Decimal(1), encode(1, -10, Positive).ceiling()); | 223 EXPECT_EQ(Decimal(1), encode(1, -10, Positive).ceil()); |
| 224 EXPECT_EQ(Decimal(2), encode(11, -1, Positive).ceiling()); | 224 EXPECT_EQ(Decimal(2), encode(11, -1, Positive).ceil()); |
| 225 EXPECT_EQ(Decimal(2), encode(13, -1, Positive).ceiling()); | 225 EXPECT_EQ(Decimal(2), encode(13, -1, Positive).ceil()); |
| 226 EXPECT_EQ(Decimal(2), encode(15, -1, Positive).ceiling()); | 226 EXPECT_EQ(Decimal(2), encode(15, -1, Positive).ceil()); |
| 227 EXPECT_EQ(Decimal(2), encode(19, -1, Positive).ceiling()); | 227 EXPECT_EQ(Decimal(2), encode(19, -1, Positive).ceil()); |
| 228 EXPECT_EQ(Decimal(2), encode(151, -2, Positive).ceiling()); | 228 EXPECT_EQ(Decimal(2), encode(151, -2, Positive).ceil()); |
| 229 EXPECT_EQ(Decimal(2), encode(101, -2, Positive).ceiling()); | 229 EXPECT_EQ(Decimal(2), encode(101, -2, Positive).ceil()); |
| 230 EXPECT_EQ(Decimal(1), encode(199, -3, Positive).ceiling()); | 230 EXPECT_EQ(Decimal(1), encode(199, -3, Positive).ceil()); |
| 231 EXPECT_EQ(Decimal(2), encode(199, -2, Positive).ceiling()); | 231 EXPECT_EQ(Decimal(2), encode(199, -2, Positive).ceil()); |
| 232 EXPECT_EQ(Decimal(3), encode(209, -2, Positive).ceiling()); | 232 EXPECT_EQ(Decimal(3), encode(209, -2, Positive).ceil()); |
| 233 | 233 |
| 234 EXPECT_EQ(Decimal(-1), Decimal(-1).ceiling()); | 234 EXPECT_EQ(Decimal(-1), Decimal(-1).ceil()); |
| 235 EXPECT_EQ(Decimal(0), encode(1, -10, Negative).ceiling()); | 235 EXPECT_EQ(Decimal(0), encode(1, -10, Negative).ceil()); |
| 236 EXPECT_EQ(Decimal(-1), encode(11, -1, Negative).ceiling()); | 236 EXPECT_EQ(Decimal(-1), encode(11, -1, Negative).ceil()); |
| 237 EXPECT_EQ(Decimal(-1), encode(13, -1, Negative).ceiling()); | 237 EXPECT_EQ(Decimal(-1), encode(13, -1, Negative).ceil()); |
| 238 EXPECT_EQ(Decimal(-1), encode(15, -1, Negative).ceiling()); | 238 EXPECT_EQ(Decimal(-1), encode(15, -1, Negative).ceil()); |
| 239 EXPECT_EQ(Decimal(-1), encode(19, -1, Negative).ceiling()); | 239 EXPECT_EQ(Decimal(-1), encode(19, -1, Negative).ceil()); |
| 240 EXPECT_EQ(Decimal(-1), encode(151, -2, Negative).ceiling()); | 240 EXPECT_EQ(Decimal(-1), encode(151, -2, Negative).ceil()); |
| 241 EXPECT_EQ(Decimal(-1), encode(101, -2, Negative).ceiling()); | 241 EXPECT_EQ(Decimal(-1), encode(101, -2, Negative).ceil()); |
| 242 EXPECT_EQ(Decimal(0), encode(199, -3, Negative).ceiling()); | 242 EXPECT_EQ(Decimal(0), encode(199, -3, Negative).ceil()); |
| 243 EXPECT_EQ(Decimal(-1), encode(199, -2, Negative).ceiling()); | 243 EXPECT_EQ(Decimal(-1), encode(199, -2, Negative).ceil()); |
| 244 EXPECT_EQ(Decimal(-2), encode(209, -2, Negative).ceiling()); | 244 EXPECT_EQ(Decimal(-2), encode(209, -2, Negative).ceil()); |
| 245 } | 245 } |
| 246 | 246 |
| 247 TEST_F(DecimalTest, CeilingBigExponent) | 247 TEST_F(DecimalTest, CeilingBigExponent) |
| 248 { | 248 { |
| 249 EXPECT_EQ(encode(1, 1000, Positive), encode(1, 1000, Positive).ceiling()); | 249 EXPECT_EQ(encode(1, 1000, Positive), encode(1, 1000, Positive).ceil()); |
| 250 EXPECT_EQ(encode(1, 1000, Negative), encode(1, 1000, Negative).ceiling()); | 250 EXPECT_EQ(encode(1, 1000, Negative), encode(1, 1000, Negative).ceil()); |
| 251 } | 251 } |
| 252 | 252 |
| 253 TEST_F(DecimalTest, CeilingSmallExponent) | 253 TEST_F(DecimalTest, CeilingSmallExponent) |
| 254 { | 254 { |
| 255 EXPECT_EQ(encode(1, 0, Positive), encode(1, -1000, Positive).ceiling()); | 255 EXPECT_EQ(encode(1, 0, Positive), encode(1, -1000, Positive).ceil()); |
| 256 EXPECT_EQ(encode(0, 0, Negative), encode(1, -1000, Negative).ceiling()); | 256 EXPECT_EQ(encode(0, 0, Negative), encode(1, -1000, Negative).ceil()); |
| 257 } | 257 } |
| 258 | 258 |
| 259 TEST_F(DecimalTest, CeilingSpecialValues) | 259 TEST_F(DecimalTest, CeilingSpecialValues) |
| 260 { | 260 { |
| 261 EXPECT_EQ(Decimal::infinity(Positive), Decimal::infinity(Positive).ceiling()
); | 261 EXPECT_EQ(Decimal::infinity(Positive), Decimal::infinity(Positive).ceil()); |
| 262 EXPECT_EQ(Decimal::infinity(Negative), Decimal::infinity(Negative).ceiling()
); | 262 EXPECT_EQ(Decimal::infinity(Negative), Decimal::infinity(Negative).ceil()); |
| 263 EXPECT_EQ(Decimal::nan(), Decimal::nan().ceiling()); | 263 EXPECT_EQ(Decimal::nan(), Decimal::nan().ceil()); |
| 264 } | 264 } |
| 265 | 265 |
| 266 TEST_F(DecimalTest, Compare) | 266 TEST_F(DecimalTest, Compare) |
| 267 { | 267 { |
| 268 EXPECT_TRUE(Decimal(0) == Decimal(0)); | 268 EXPECT_TRUE(Decimal(0) == Decimal(0)); |
| 269 EXPECT_TRUE(Decimal(0) != Decimal(1)); | 269 EXPECT_TRUE(Decimal(0) != Decimal(1)); |
| 270 EXPECT_TRUE(Decimal(0) < Decimal(1)); | 270 EXPECT_TRUE(Decimal(0) < Decimal(1)); |
| 271 EXPECT_TRUE(Decimal(0) <= Decimal(0)); | 271 EXPECT_TRUE(Decimal(0) <= Decimal(0)); |
| 272 EXPECT_TRUE(Decimal(0) > Decimal(-1)); | 272 EXPECT_TRUE(Decimal(0) > Decimal(-1)); |
| 273 EXPECT_TRUE(Decimal(0) >= Decimal(0)); | 273 EXPECT_TRUE(Decimal(0) >= Decimal(0)); |
| (...skipping 840 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 } |
| OLD | NEW |