From f171b34cf045115b82ccb89b57feb56d3cad472b Mon Sep 17 00:00:00 2001 From: Christopher Ferris Date: Mon, 17 Mar 2014 16:40:26 -0700 Subject: [PATCH] Use the float/double assert macros. The normal ASSERT_EQ macros don't work quite right for float/double values, and result in false failures. Use the correct macros instead. Bug: 13511379 Change-Id: Ic2feee7f3d3569f57b6453b8fa95222846c625cd --- tests/stdio_test.cpp | 2 +- tests/stdlib_test.cpp | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/stdio_test.cpp b/tests/stdio_test.cpp index 893e057b7..8c1cef901 100644 --- a/tests/stdio_test.cpp +++ b/tests/stdio_test.cpp @@ -381,5 +381,5 @@ TEST(stdio, sscanf) { ASSERT_EQ(3, sscanf(" hello 123 1.23 ", "%s %i %lf %s", s1, &i1, &d1, s2)); ASSERT_STREQ("hello", s1); ASSERT_EQ(123, i1); - ASSERT_EQ(1.23, d1); + ASSERT_DOUBLE_EQ(1.23, d1); } diff --git a/tests/stdlib_test.cpp b/tests/stdlib_test.cpp index 7bdb685d5..3a3fe28ae 100644 --- a/tests/stdlib_test.cpp +++ b/tests/stdlib_test.cpp @@ -188,17 +188,17 @@ TEST(stdlib, system) { } TEST(stdlib, atof) { - ASSERT_EQ(1.23, atof("1.23")); + ASSERT_DOUBLE_EQ(1.23, atof("1.23")); } TEST(stdlib, strtod) { - ASSERT_EQ(1.23, strtod("1.23", NULL)); + ASSERT_DOUBLE_EQ(1.23, strtod("1.23", NULL)); } TEST(stdlib, strtof) { - ASSERT_EQ(1.23, strtod("1.23", NULL)); + ASSERT_FLOAT_EQ(1.23, strtof("1.23", NULL)); } TEST(stdlib, strtold) { - ASSERT_EQ(1.23, strtold("1.23", NULL)); + ASSERT_DOUBLE_EQ(1.23, strtold("1.23", NULL)); }