[PATCH 4/4] ucrtbase/tests: Check errno in strtod tests.

Daniel Lehman dlehman25 at gmail.com
Wed Jul 15 13:36:31 CDT 2020


Signed-off-by: Daniel Lehman <dlehman25 at gmail.com>
---
 dlls/ucrtbase/tests/string.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/dlls/ucrtbase/tests/string.c b/dlls/ucrtbase/tests/string.c
index f85f9abf73..1a51784af0 100644
--- a/dlls/ucrtbase/tests/string.c
+++ b/dlls/ucrtbase/tests/string.c
@@ -77,12 +77,15 @@ static BOOL local_isnan(double d)
     return d != d;
 }
 
-#define test_strtod_str(string, value, length) _test_strtod_str(__LINE__, string, value, length)
-static void _test_strtod_str(int line, const char* string, double value, int length)
+#define test_strtod_str_errno(string, value, length, err) _test_strtod_str(__LINE__, string, value, length, err)
+#define test_strtod_str(string, value, length) _test_strtod_str(__LINE__, string, value, length, 0)
+static void _test_strtod_str(int line, const char* string, double value, int length, int err)
 {
     char *end;
     double d;
+    errno = 0xdeadbeef;
     d = strtod(string, &end);
+    ok(!err || errno == err, "errno = %d\n", errno);
     if (local_isnan(value))
         ok_(__FILE__, line)(local_isnan(d), "d = %.16le (\"%s\")\n", d, string);
     else
@@ -102,6 +105,8 @@ static void test_strtod(void)
     test_strtod_str("infini", INFINITY, 3);
     test_strtod_str("input", 0, 0);
     test_strtod_str("-input", 0, 0);
+    test_strtod_str_errno("1.7976931348623159e+308", INFINITY, 23, ERANGE);
+    test_strtod_str_errno("-1.7976931348623159e+308", -INFINITY, 24, ERANGE);
 
     test_strtod_str("NAN", NAN, 3);
     test_strtod_str("nan", NAN, 3);
@@ -137,6 +142,7 @@ static void test_strtod(void)
 
     test_strtod_str("4.0621786324484881721115322e-53", 4.0621786324484881721115322e-53, 31);
     test_strtod_str("1.8905590910042396899370942", 1.8905590910042396899370942, 27);
+    test_strtod_str("1.7976931348623158e+308", 1.7976931348623158e+308, 23);
     test_strtod_str("2.2250738585072014e-308", 2.2250738585072014e-308, 23);
     test_strtod_str("4.9406564584124654e-324", 4.9406564584124654e-324, 23);
 }
-- 
2.25.1




More information about the wine-devel mailing list