[PATCH 5/5] ucrtbase/tests: Add tests for errno with math functions.
Alex Henrie
alexhenrie24 at gmail.com
Mon Jul 17 23:33:55 CDT 2017
Signed-off-by: Alex Henrie <alexhenrie24 at gmail.com>
---
dlls/ucrtbase/tests/misc.c | 54 +++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 53 insertions(+), 1 deletion(-)
diff --git a/dlls/ucrtbase/tests/misc.c b/dlls/ucrtbase/tests/misc.c
index 213700f114..b8db434812 100644
--- a/dlls/ucrtbase/tests/misc.c
+++ b/dlls/ucrtbase/tests/misc.c
@@ -55,6 +55,8 @@
expect_ ## func = called_ ## func = FALSE; \
}while(0)
+#define INF 1.0/0.0
+
DEFINE_EXPECT(global_invalid_parameter_handler);
DEFINE_EXPECT(thread_invalid_parameter_handler);
@@ -72,6 +74,8 @@ typedef struct MSVCRT__lldiv_t {
LONGLONG rem; /* remainder */
} MSVCRT_lldiv_t;
+static HMODULE module;
+
static int (CDECL *p_initialize_onexit_table)(MSVCRT__onexit_table_t *table);
static int (CDECL *p_register_onexit_function)(MSVCRT__onexit_table_t *table, MSVCRT__onexit_t func);
static int (CDECL *p_execute_onexit_table)(MSVCRT__onexit_table_t *table);
@@ -92,6 +96,7 @@ static int (CDECL *p__isblank_l)(int,_locale_t);
static int (CDECL *p__iswctype_l)(int,int,_locale_t);
static int (CDECL *p_iswblank)(int);
static int (CDECL *p__iswblank_l)(wint_t,_locale_t);
+static int* (CDECL *p_errno)(void);
static void test__initialize_onexit_table(void)
{
@@ -365,7 +370,7 @@ static void test__get_narrow_winmain_command_line(char *path)
static BOOL init(void)
{
- HMODULE module = LoadLibraryA("ucrtbase.dll");
+ module = LoadLibraryA("ucrtbase.dll");
if(!module) {
win_skip("ucrtbase.dll not available\n");
@@ -392,6 +397,7 @@ static BOOL init(void)
p__iswctype_l = (void*)GetProcAddress(module, "_iswctype_l");
p_iswblank = (void*)GetProcAddress(module, "iswblank");
p__iswblank_l = (void*)GetProcAddress(module, "_iswblank_l");
+ p_errno = (void*)GetProcAddress(module, "_errno");
return TRUE;
}
@@ -509,6 +515,51 @@ static void test_isblank(void)
}
}
+static void test_math_errno(void)
+{
+ static const struct {
+ char func[8];
+ double x;
+ int err;
+ } tests[] = {
+ {"acosh", 0, EDOM},
+ {"acosh", 1, -1},
+ {"atanh", -2, EDOM},
+ {"atanh", -1, ERANGE},
+ {"atanh", 1, ERANGE},
+ {"atanh", 2, EDOM},
+ {"exp", -INF, -1},
+ {"exp", INF, -1},
+ {"expm1", -INF, -1},
+ {"expm1", INF, -1},
+ {"log", -INF, EDOM},
+ {"log", -1, EDOM},
+ {"log", 0, ERANGE},
+ {"log", INF, -1},
+ {"log10", -INF, EDOM},
+ {"log10", -1, EDOM},
+ {"log10", 0, ERANGE},
+ {"log10", INF, -1},
+ {"log1p", -INF, EDOM},
+ {"log1p", -2, EDOM},
+ {"log1p", -1, ERANGE},
+ {"log1p", INF, -1},
+ {"log2", -INF, EDOM},
+ {"log2", -1, EDOM},
+ {"log2", 0, ERANGE},
+ {"log2", INF, -1},
+ };
+ double (CDECL *p_func)(double);
+ int i;
+
+ for(i = 0; i < sizeof(tests)/sizeof(tests[0]); i++) {
+ p_func = (void*)GetProcAddress(module, tests[i].func);
+ *p_errno() = -1;
+ p_func(tests[i].x);
+ ok(*p_errno() == tests[i].err, "%s(%f) got errno %d\n", tests[i].func, tests[i].x, *p_errno());
+ }
+}
+
START_TEST(misc)
{
int arg_c;
@@ -533,4 +584,5 @@ START_TEST(misc)
test__sopen_s();
test_lldiv();
test_isblank();
+ test_math_errno();
}
--
2.13.3
More information about the wine-patches
mailing list