aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarco Paland <marco@paland.com>2018-05-12 01:43:43 +0200
committerMarco Paland <marco@paland.com>2018-05-12 01:43:43 +0200
commita6e81f9c598e722571b9ae115fda6ef770a57e66 (patch)
tree12b00e8f22ed09e7ea5446581c65542737e19b85
parentee383ad5c7b5bbf60b4af447c5114e95a734688d (diff)
downloadprintf-a6e81f9c598e722571b9ae115fda6ef770a57e66.tar.gz
printf-a6e81f9c598e722571b9ae115fda6ef770a57e66.tar.bz2
printf-a6e81f9c598e722571b9ae115fda6ef770a57e66.zip
test(test_suite): added more `float` test cases
-rw-r--r--README.md2
-rw-r--r--test/test_suite.cpp27
2 files changed, 28 insertions, 1 deletions
diff --git a/README.md b/README.md
index 1e2af49..2c16afd 100644
--- a/README.md
+++ b/README.md
@@ -28,7 +28,7 @@ Therefore I decided to write an own, final implementation which meets the follow
- Support of decimal/floating number representation (with an own fast itoa/ftoa)
- Reentrant and thread-safe, malloc free, no static vars/buffers
- LINT and compiler L4 warning free, mature, coverity clean, automotive ready
- - Extensive test suite (> 310 test cases) passing
+ - Extensive test suite (> 320 test cases) passing
- Simply the best *printf* around the net
- MIT license
diff --git a/test/test_suite.cpp b/test/test_suite.cpp
index c801c5f..a5c087c 100644
--- a/test/test_suite.cpp
+++ b/test/test_suite.cpp
@@ -899,6 +899,22 @@ TEST_CASE("float", "[]" ) {
test::sprintf(buffer, "%.9f", -12345.987654321);
REQUIRE(!strcmp(buffer, "-12345.987654321"));
+
+ test::sprintf(buffer, "%.1f", 3.999);
+ REQUIRE(!strcmp(buffer, "4.0"));
+
+ test::sprintf(buffer, "%.0f", 3.5);
+ REQUIRE(!strcmp(buffer, "4"));
+
+ test::sprintf(buffer, "%.0f", 3.49);
+ REQUIRE(!strcmp(buffer, "3"));
+
+ test::sprintf(buffer, "%.1f", 3.49);
+ REQUIRE(!strcmp(buffer, "3.5"));
+
+ // out of range in the moment, need to be fixed by someone
+ test::sprintf(buffer, "%.1f", 1E20);
+ REQUIRE(!strcmp(buffer, ""));
}
@@ -1006,6 +1022,17 @@ TEST_CASE("types", "[]" ) {
test::sprintf(buffer, "%tx", &buffer[10] - &buffer[0]);
REQUIRE(!strcmp(buffer, "a"));
+
+// TBD
+ if (sizeof(intmax_t) == sizeof(long)) {
+ test::sprintf(buffer, "%ji", -2147483647L);
+ REQUIRE(!strcmp(buffer, "-2147483647"));
+ }
+ else {
+ test::sprintf(buffer, "%ji", -2147483647LL);
+ REQUIRE(!strcmp(buffer, "-2147483647"));
+ }
+
}