From a59b98bb0cac4668c46e7ed090edef215132168c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Storsj=C3=B6?= Date: Mon, 8 Apr 2019 14:28:25 +0300 Subject: [PATCH] crt-test: Test error reporting of CRT functions via errno --- test/crt-test.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/test/crt-test.c b/test/crt-test.c index 21be41e..fa3e1e6 100644 --- a/test/crt-test.c +++ b/test/crt-test.c @@ -26,10 +26,16 @@ #include #include #include +#include #ifdef _WIN32 #include #endif +#ifdef _WIN32 +static void invalid_parameter(const wchar_t *expression, const wchar_t *function, const wchar_t *file, unsigned int line, uintptr_t pReserved) { +} +#endif + int tests = 0, fails = 0; const char *context = ""; @@ -170,6 +176,13 @@ int main(int argc, char* argv[]) { } tests++; +#ifdef _WIN32 + _set_invalid_parameter_handler(invalid_parameter); +#endif + errno = 0; + TEST_INT(strtol("foo", NULL, 100), 0); + TEST_INT(errno, EINVAL); + TEST_FLT(floor(F(3.9)), 3.0); TEST_FLT(floor(F(17179869184.0)), 17179869184.0); TEST_FLT(floor(F(-3.3)), -4.0);