aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorVictor Zverovich <victor.zverovich@gmail.com>2019-10-13 11:36:21 -0700
committerVictor Zverovich <victor.zverovich@gmail.com>2019-10-13 12:50:48 -0700
commit1cbc5fa6cbdda55bf868ada97ebe7e2773297c43 (patch)
tree7182b2f776bb3e02ca822aabd04dde41cb301e6e /test
parentf7a5748fd3e23974cd45a5f6a7775ddbe7735876 (diff)
downloadfmtlib-1cbc5fa6cbdda55bf868ada97ebe7e2773297c43.tar.gz
Handle negative exponent and rename value/pow10 to numerator/denominator
Diffstat (limited to 'test')
-rw-r--r--test/format-impl-test.cc9
-rw-r--r--test/grisu-test.cc9
2 files changed, 15 insertions, 3 deletions
diff --git a/test/format-impl-test.cc b/test/format-impl-test.cc
index 5b7946e0..c3f81904 100644
--- a/test/format-impl-test.cc
+++ b/test/format-impl-test.cc
@@ -87,16 +87,19 @@ TEST(BigIntTest, ShiftLeft) {
TEST(BigIntTest, Multiply) {
bigint n(0x42);
+ EXPECT_THROW(n *= 0, assertion_failure);
n *= 1;
EXPECT_EQ("42", fmt::format("{}", n));
n *= 2;
EXPECT_EQ("84", fmt::format("{}", n));
n *= 0x12345678;
EXPECT_EQ("962fc95e0", fmt::format("{}", n));
- auto max = max_value<uint32_t>();
- bigint bigmax(max);
- bigmax *= max;
+ bigint bigmax(max_value<uint32_t>());
+ bigmax *= max_value<uint32_t>();
EXPECT_EQ("fffffffe00000001", fmt::format("{}", bigmax));
+ bigmax.assign(max_value<uint64_t>());
+ bigmax *= max_value<uint64_t>();
+ EXPECT_EQ("fffffffffffffffe0000000000000001", fmt::format("{}", bigmax));
}
TEST(BigIntTest, Accumulator) {
diff --git a/test/grisu-test.cc b/test/grisu-test.cc
index 79a13191..80121055 100644
--- a/test/grisu-test.cc
+++ b/test/grisu-test.cc
@@ -55,3 +55,12 @@ TEST(GrisuTest, Prettify) {
}
TEST(GrisuTest, ZeroPrecision) { EXPECT_EQ("1", fmt::format("{:.0}", 1.0)); }
+
+TEST(GrisuTest, Fallback) {
+ EXPECT_EQ("1e+23", fmt::format("{}", 1e23));
+ EXPECT_EQ("9e-265", fmt::format("{}", 9e-265));
+ EXPECT_EQ("5.423717798060526e+125",
+ fmt::format("{}", 5.423717798060526e+125));
+ EXPECT_EQ("1.372371880954233e-288",
+ fmt::format("{}", 1.372371880954233e-288));
+}