aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorMarco Paland <marco@paland.com>2019-01-31 19:16:30 +0100
committerMarco Paland <marco@paland.com>2019-01-31 19:16:30 +0100
commit369b7bbc988c509d68d7d62a1c438f5a8caf3835 (patch)
treef98c7912c5fa14735c5436915538d1a4326e3137 /test
parente9375ed897cd86c72c9140e7ef88c184506d176c (diff)
downloadprintf-369b7bbc988c509d68d7d62a1c438f5a8caf3835.tar.gz
printf-369b7bbc988c509d68d7d62a1c438f5a8caf3835.tar.bz2
printf-369b7bbc988c509d68d7d62a1c438f5a8caf3835.zip
fix(printf): remove float comparison
Add more float test cases
Diffstat (limited to 'test')
-rw-r--r--test/test_suite.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/test/test_suite.cpp b/test/test_suite.cpp
index e3630d7..00e5f48 100644
--- a/test/test_suite.cpp
+++ b/test/test_suite.cpp
@@ -1036,6 +1036,15 @@ TEST_CASE("float", "[]" ) {
test::sprintf(buffer, "%.0f", 34.1415354);
REQUIRE(!strcmp(buffer, "34"));
+ test::sprintf(buffer, "%.0f", 1.3);
+ REQUIRE(!strcmp(buffer, "1"));
+
+ test::sprintf(buffer, "%.0f", 1.55);
+ REQUIRE(!strcmp(buffer, "2"));
+
+ test::sprintf(buffer, "%.1f", 1.64);
+ REQUIRE(!strcmp(buffer, "1.6"));
+
test::sprintf(buffer, "%.2f", 42.8952);
REQUIRE(!strcmp(buffer, "42.90"));
@@ -1082,6 +1091,9 @@ TEST_CASE("float", "[]" ) {
test::sprintf(buffer, "%.0f", 3.5);
REQUIRE(!strcmp(buffer, "4"));
+ test::sprintf(buffer, "%.0f", 4.5);
+ REQUIRE(!strcmp(buffer, "4"));
+
test::sprintf(buffer, "%.0f", 3.49);
REQUIRE(!strcmp(buffer, "3"));