[libcxx] r349522 - Rework the C strings tests to use ASSERT_SAME_TYPE. NFC there. Also change cwchar.pass.cpp to avoid constructing a couple things from zero - since apparently they can be enums in some weird C library. NFC there, either, since the values were never used.

Marshall Clow mclow.lists at gmail.com
Tue Dec 18 11:07:30 PST 2018


Author: marshall
Date: Tue Dec 18 11:07:30 2018
New Revision: 349522

URL: http://llvm.org/viewvc/llvm-project?rev=349522&view=rev
Log:
Rework the C strings tests to use ASSERT_SAME_TYPE. NFC there. Also change cwchar.pass.cpp to avoid constructing a couple things from zero - since apparently they can be enums in some weird C library. NFC there, either, since the values were never used.

Modified:
    libcxx/trunk/test/std/strings/c.strings/cctype.pass.cpp
    libcxx/trunk/test/std/strings/c.strings/cstring.pass.cpp
    libcxx/trunk/test/std/strings/c.strings/cuchar.pass.cpp
    libcxx/trunk/test/std/strings/c.strings/cwchar.pass.cpp
    libcxx/trunk/test/std/strings/c.strings/cwctype.pass.cpp

Modified: libcxx/trunk/test/std/strings/c.strings/cctype.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/strings/c.strings/cctype.pass.cpp?rev=349522&r1=349521&r2=349522&view=diff
==============================================================================
--- libcxx/trunk/test/std/strings/c.strings/cctype.pass.cpp (original)
+++ libcxx/trunk/test/std/strings/c.strings/cctype.pass.cpp Tue Dec 18 11:07:30 2018
@@ -13,6 +13,8 @@
 #include <type_traits>
 #include <cassert>
 
+#include "test_macros.h"
+
 #ifdef isalnum
 #error isalnum defined
 #endif
@@ -71,33 +73,34 @@
 
 int main()
 {
-    static_assert((std::is_same<decltype(std::isalnum(0)), int>::value), "");
-    static_assert((std::is_same<decltype(std::isalpha(0)), int>::value), "");
-    static_assert((std::is_same<decltype(std::isblank(0)), int>::value), "");
-    static_assert((std::is_same<decltype(std::iscntrl(0)), int>::value), "");
-    static_assert((std::is_same<decltype(std::isdigit(0)), int>::value), "");
-    static_assert((std::is_same<decltype(std::isgraph(0)), int>::value), "");
-    static_assert((std::is_same<decltype(std::islower(0)), int>::value), "");
-    static_assert((std::is_same<decltype(std::isprint(0)), int>::value), "");
-    static_assert((std::is_same<decltype(std::ispunct(0)), int>::value), "");
-    static_assert((std::is_same<decltype(std::isspace(0)), int>::value), "");
-    static_assert((std::is_same<decltype(std::isupper(0)), int>::value), "");
-    static_assert((std::is_same<decltype(std::isxdigit(0)), int>::value), "");
-    static_assert((std::is_same<decltype(std::tolower(0)), int>::value), "");
-    static_assert((std::is_same<decltype(std::toupper(0)), int>::value), "");
-
-    assert(std::isalnum('a'));
-    assert(std::isalpha('a'));
-    assert(std::isblank(' '));
+
+    ASSERT_SAME_TYPE(int, decltype(std::isalnum(0)));
+    ASSERT_SAME_TYPE(int, decltype(std::isalpha(0)));
+    ASSERT_SAME_TYPE(int, decltype(std::isblank(0)));
+    ASSERT_SAME_TYPE(int, decltype(std::iscntrl(0)));
+    ASSERT_SAME_TYPE(int, decltype(std::isdigit(0)));
+    ASSERT_SAME_TYPE(int, decltype(std::isgraph(0)));
+    ASSERT_SAME_TYPE(int, decltype(std::islower(0)));
+    ASSERT_SAME_TYPE(int, decltype(std::isprint(0)));
+    ASSERT_SAME_TYPE(int, decltype(std::ispunct(0)));
+    ASSERT_SAME_TYPE(int, decltype(std::isspace(0)));
+    ASSERT_SAME_TYPE(int, decltype(std::isupper(0)));
+    ASSERT_SAME_TYPE(int, decltype(std::isxdigit(0)));
+    ASSERT_SAME_TYPE(int, decltype(std::tolower(0)));
+    ASSERT_SAME_TYPE(int, decltype(std::toupper(0)));
+
+    assert( std::isalnum('a'));
+    assert( std::isalpha('a'));
+    assert( std::isblank(' '));
     assert(!std::iscntrl(' '));
     assert(!std::isdigit('a'));
-    assert(std::isgraph('a'));
-    assert(std::islower('a'));
-    assert(std::isprint('a'));
+    assert( std::isgraph('a'));
+    assert( std::islower('a'));
+    assert( std::isprint('a'));
     assert(!std::ispunct('a'));
     assert(!std::isspace('a'));
     assert(!std::isupper('a'));
-    assert(std::isxdigit('a'));
-    assert(std::tolower('A') == 'a');
-    assert(std::toupper('a') == 'A');
+    assert( std::isxdigit('a'));
+    assert( std::tolower('A') == 'a');
+    assert( std::toupper('a') == 'A');
 }

Modified: libcxx/trunk/test/std/strings/c.strings/cstring.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/strings/c.strings/cstring.pass.cpp?rev=349522&r1=349521&r2=349522&view=diff
==============================================================================
--- libcxx/trunk/test/std/strings/c.strings/cstring.pass.cpp (original)
+++ libcxx/trunk/test/std/strings/c.strings/cstring.pass.cpp Tue Dec 18 11:07:30 2018
@@ -12,6 +12,8 @@
 #include <cstring>
 #include <type_traits>
 
+#include "test_macros.h"
+
 #ifndef NULL
 #error NULL not defined
 #endif
@@ -23,39 +25,40 @@ int main()
     const void* vpc = 0;
     char* cp = 0;
     const char* cpc = 0;
-    static_assert((std::is_same<decltype(std::memcpy(vp, vpc, s)), void*>::value), "");
-    static_assert((std::is_same<decltype(std::memmove(vp, vpc, s)), void*>::value), "");
-    static_assert((std::is_same<decltype(std::strcpy(cp, cpc)), char*>::value), "");
-    static_assert((std::is_same<decltype(std::strncpy(cp, cpc, s)), char*>::value), "");
-    static_assert((std::is_same<decltype(std::strcat(cp, cpc)), char*>::value), "");
-    static_assert((std::is_same<decltype(std::strncat(cp, cpc, s)), char*>::value), "");
-    static_assert((std::is_same<decltype(std::memcmp(vpc, vpc, s)), int>::value), "");
-    static_assert((std::is_same<decltype(std::strcmp(cpc, cpc)), int>::value), "");
-    static_assert((std::is_same<decltype(std::strncmp(cpc, cpc, s)), int>::value), "");
-    static_assert((std::is_same<decltype(std::strcoll(cpc, cpc)), int>::value), "");
-    static_assert((std::is_same<decltype(std::strxfrm(cp, cpc, s)), std::size_t>::value), "");
-    static_assert((std::is_same<decltype(std::memchr(vp, 0, s)), void*>::value), "");
-    static_assert((std::is_same<decltype(std::strchr(cp, 0)), char*>::value), "");
-    static_assert((std::is_same<decltype(std::strcspn(cpc, cpc)), std::size_t>::value), "");
-    static_assert((std::is_same<decltype(std::strpbrk(cp, cpc)), char*>::value), "");
-    static_assert((std::is_same<decltype(std::strrchr(cp, 0)), char*>::value), "");
-    static_assert((std::is_same<decltype(std::strspn(cpc, cpc)), std::size_t>::value), "");
-    static_assert((std::is_same<decltype(std::strstr(cp, cpc)), char*>::value), "");
+
+    ASSERT_SAME_TYPE(void*,       decltype(std::memcpy(vp, vpc, s)));
+    ASSERT_SAME_TYPE(void*,       decltype(std::memmove(vp, vpc, s)));
+    ASSERT_SAME_TYPE(char*,       decltype(std::strcpy(cp, cpc)));
+    ASSERT_SAME_TYPE(char*,       decltype(std::strncpy(cp, cpc, s)));
+    ASSERT_SAME_TYPE(char*,       decltype(std::strcat(cp, cpc)));
+    ASSERT_SAME_TYPE(char*,       decltype(std::strncat(cp, cpc, s)));
+    ASSERT_SAME_TYPE(int,         decltype(std::memcmp(vpc, vpc, s)));
+    ASSERT_SAME_TYPE(int,         decltype(std::strcmp(cpc, cpc)));
+    ASSERT_SAME_TYPE(int,         decltype(std::strncmp(cpc, cpc, s)));
+    ASSERT_SAME_TYPE(int,         decltype(std::strcoll(cpc, cpc)));
+    ASSERT_SAME_TYPE(std::size_t, decltype(std::strxfrm(cp, cpc, s)));
+    ASSERT_SAME_TYPE(void*,       decltype(std::memchr(vp, 0, s)));
+    ASSERT_SAME_TYPE(char*,       decltype(std::strchr(cp, 0)));
+    ASSERT_SAME_TYPE(std::size_t, decltype(std::strcspn(cpc, cpc)));
+    ASSERT_SAME_TYPE(char*,       decltype(std::strpbrk(cp, cpc)));
+    ASSERT_SAME_TYPE(char*,       decltype(std::strrchr(cp, 0)));
+    ASSERT_SAME_TYPE(std::size_t, decltype(std::strspn(cpc, cpc)));
+    ASSERT_SAME_TYPE(char*,       decltype(std::strstr(cp, cpc)));
 #ifndef _LIBCPP_HAS_NO_THREAD_UNSAFE_C_FUNCTIONS
-    static_assert((std::is_same<decltype(std::strtok(cp, cpc)), char*>::value), "");
+    ASSERT_SAME_TYPE(char*,       decltype(std::strtok(cp, cpc)));
 #endif
-    static_assert((std::is_same<decltype(std::memset(vp, 0, s)), void*>::value), "");
-    static_assert((std::is_same<decltype(std::strerror(0)), char*>::value), "");
-    static_assert((std::is_same<decltype(std::strlen(cpc)), std::size_t>::value), "");
+    ASSERT_SAME_TYPE(void*,       decltype(std::memset(vp, 0, s)));
+    ASSERT_SAME_TYPE(char*,       decltype(std::strerror(0)));
+    ASSERT_SAME_TYPE(std::size_t, decltype(std::strlen(cpc)));
 
     // These tests fail on systems whose C library doesn't provide a correct overload
     // set for strchr, strpbrk, strrchr, strstr, and memchr, unless the compiler is
     // a suitably recent version of Clang.
 #if !defined(__APPLE__) || defined(_LIBCPP_PREFERRED_OVERLOAD)
-    static_assert((std::is_same<decltype(std::memchr(vpc, 0, s)), const void*>::value), "");
-    static_assert((std::is_same<decltype(std::strchr(cpc, 0)), const char*>::value), "");
-    static_assert((std::is_same<decltype(std::strpbrk(cpc, cpc)), const char*>::value), "");
-    static_assert((std::is_same<decltype(std::strrchr(cpc, 0)), const char*>::value), "");
-    static_assert((std::is_same<decltype(std::strstr(cpc, cpc)), const char*>::value), "");
+    ASSERT_SAME_TYPE(const void*, decltype(std::memchr(vpc, 0, s)));
+    ASSERT_SAME_TYPE(const char*, decltype(std::strchr(cpc, 0)));
+    ASSERT_SAME_TYPE(const char*, decltype(std::strpbrk(cpc, cpc)));
+    ASSERT_SAME_TYPE(const char*, decltype(std::strrchr(cpc, 0)));
+    ASSERT_SAME_TYPE(const char*, decltype(std::strstr(cpc, cpc)));
 #endif
 }

Modified: libcxx/trunk/test/std/strings/c.strings/cuchar.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/strings/c.strings/cuchar.pass.cpp?rev=349522&r1=349521&r2=349522&view=diff
==============================================================================
--- libcxx/trunk/test/std/strings/c.strings/cuchar.pass.cpp (original)
+++ libcxx/trunk/test/std/strings/c.strings/cuchar.pass.cpp Tue Dec 18 11:07:30 2018
@@ -13,6 +13,8 @@
 
 #include <cuchar>
 
+#include "test_macros.h"
+
 int main()
 {
 }

Modified: libcxx/trunk/test/std/strings/c.strings/cwchar.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/strings/c.strings/cwchar.pass.cpp?rev=349522&r1=349521&r2=349522&view=diff
==============================================================================
--- libcxx/trunk/test/std/strings/c.strings/cwchar.pass.cpp (original)
+++ libcxx/trunk/test/std/strings/c.strings/cwchar.pass.cpp Tue Dec 18 11:07:30 2018
@@ -13,6 +13,8 @@
 #include <cstdarg>
 #include <type_traits>
 
+#include "test_macros.h"
+
 #ifndef NULL
 #error NULL not defined
 #endif
@@ -50,80 +52,80 @@ int main()
     ((void)ns); // Prevent unused warning
     ((void)ws); // Prevent unused warning
 
-    static_assert((std::is_same<decltype(std::fwprintf(fp, L"")), int>::value), "");
-    static_assert((std::is_same<decltype(std::fwscanf(fp, L"")), int>::value), "");
-    static_assert((std::is_same<decltype(std::swprintf(ws, s, L"")), int>::value), "");
-    static_assert((std::is_same<decltype(std::swscanf(L"", L"")), int>::value), "");
-    static_assert((std::is_same<decltype(std::vfwprintf(fp, L"", va)), int>::value), "");
-    static_assert((std::is_same<decltype(std::vfwscanf(fp, L"", va)), int>::value), "");
-    static_assert((std::is_same<decltype(std::vswprintf(ws, s, L"", va)), int>::value), "");
-    static_assert((std::is_same<decltype(std::vswscanf(L"", L"", va)), int>::value), "");
-    static_assert((std::is_same<decltype(std::fgetwc(fp)), std::wint_t>::value), "");
-    static_assert((std::is_same<decltype(std::fgetws(ws, 0, fp)), wchar_t*>::value), "");
-    static_assert((std::is_same<decltype(std::fputwc(L' ', fp)), std::wint_t>::value), "");
-    static_assert((std::is_same<decltype(std::fputws(L"", fp)), int>::value), "");
-    static_assert((std::is_same<decltype(std::fwide(fp, 0)), int>::value), "");
-    static_assert((std::is_same<decltype(std::getwc(fp)), std::wint_t>::value), "");
-    static_assert((std::is_same<decltype(std::putwc(L' ', fp)), std::wint_t>::value), "");
-    static_assert((std::is_same<decltype(std::ungetwc(L' ', fp)), std::wint_t>::value), "");
-    static_assert((std::is_same<decltype(std::wcstod(L"", (wchar_t**)0)), double>::value), "");
-    static_assert((std::is_same<decltype(std::wcstof(L"", (wchar_t**)0)), float>::value), "");
-    static_assert((std::is_same<decltype(std::wcstold(L"", (wchar_t**)0)), long double>::value), "");
-    static_assert((std::is_same<decltype(std::wcstol(L"", (wchar_t**)0, 0)), long>::value), "");
-    static_assert((std::is_same<decltype(std::wcstoll(L"", (wchar_t**)0, 0)), long long>::value), "");
-    static_assert((std::is_same<decltype(std::wcstoul(L"", (wchar_t**)0, 0)), unsigned long>::value), "");
-    static_assert((std::is_same<decltype(std::wcstoull(L"", (wchar_t**)0, 0)), unsigned long long>::value), "");
-    static_assert((std::is_same<decltype(std::wcscpy(ws, L"")), wchar_t*>::value), "");
-    static_assert((std::is_same<decltype(std::wcsncpy(ws, L"", s)), wchar_t*>::value), "");
-    static_assert((std::is_same<decltype(std::wcscat(ws, L"")), wchar_t*>::value), "");
-    static_assert((std::is_same<decltype(std::wcsncat(ws, L"", s)), wchar_t*>::value), "");
-    static_assert((std::is_same<decltype(std::wcscmp(L"", L"")), int>::value), "");
-    static_assert((std::is_same<decltype(std::wcscoll(L"", L"")), int>::value), "");
-    static_assert((std::is_same<decltype(std::wcsncmp(L"", L"", s)), int>::value), "");
-    static_assert((std::is_same<decltype(std::wcsxfrm(ws, L"", s)), std::size_t>::value), "");
-    static_assert((std::is_same<decltype(std::wcschr((wchar_t*)0, L' ')), wchar_t*>::value), "");
-    static_assert((std::is_same<decltype(std::wcscspn(L"", L"")), std::size_t>::value), "");
-    static_assert((std::is_same<decltype(std::wcslen(L"")), std::size_t>::value), "");
-    static_assert((std::is_same<decltype(std::wcspbrk((wchar_t*)0, L"")), wchar_t*>::value), "");
-    static_assert((std::is_same<decltype(std::wcsrchr((wchar_t*)0, L' ')), wchar_t*>::value), "");
-    static_assert((std::is_same<decltype(std::wcsspn(L"", L"")), std::size_t>::value), "");
-    static_assert((std::is_same<decltype(std::wcsstr((wchar_t*)0, L"")), wchar_t*>::value), "");
-    static_assert((std::is_same<decltype(std::wcstok(ws, L"", (wchar_t**)0)), wchar_t*>::value), "");
-    static_assert((std::is_same<decltype(std::wmemchr((wchar_t*)0, L' ', s)), wchar_t*>::value), "");
-    static_assert((std::is_same<decltype(std::wmemcmp(L"", L"", s)), int>::value), "");
-    static_assert((std::is_same<decltype(std::wmemcpy(ws, L"", s)), wchar_t*>::value), "");
-    static_assert((std::is_same<decltype(std::wmemmove(ws, L"", s)), wchar_t*>::value), "");
-    static_assert((std::is_same<decltype(std::wmemset(ws, L' ', s)), wchar_t*>::value), "");
-    static_assert((std::is_same<decltype(std::wcsftime(ws, s, L"", tm)), std::size_t>::value), "");
-    static_assert((std::is_same<decltype(std::btowc(0)), wint_t>::value), "");
-    static_assert((std::is_same<decltype(std::wctob(w)), int>::value), "");
-    static_assert((std::is_same<decltype(std::mbsinit(&mb)), int>::value), "");
-    static_assert((std::is_same<decltype(std::mbrlen("", s, &mb)), std::size_t>::value), "");
-    static_assert((std::is_same<decltype(std::mbrtowc(ws, "", s, &mb)), std::size_t>::value), "");
-    static_assert((std::is_same<decltype(std::wcrtomb(ns, L' ', &mb)), std::size_t>::value), "");
-    static_assert((std::is_same<decltype(std::mbsrtowcs(ws, (const char**)0, s, &mb)), std::size_t>::value), "");
-    static_assert((std::is_same<decltype(std::wcsrtombs(ns, (const wchar_t**)0, s, &mb)), std::size_t>::value), "");
+    ASSERT_SAME_TYPE(int,                decltype(std::fwprintf(fp, L"")));
+    ASSERT_SAME_TYPE(int,                decltype(std::fwscanf(fp, L"")));
+    ASSERT_SAME_TYPE(int,                decltype(std::swprintf(ws, s, L"")));
+    ASSERT_SAME_TYPE(int,                decltype(std::swscanf(L"", L"")));
+    ASSERT_SAME_TYPE(int,                decltype(std::vfwprintf(fp, L"", va)));
+    ASSERT_SAME_TYPE(int,                decltype(std::vfwscanf(fp, L"", va)));
+    ASSERT_SAME_TYPE(int,                decltype(std::vswprintf(ws, s, L"", va)));
+    ASSERT_SAME_TYPE(int,                decltype(std::vswscanf(L"", L"", va)));
+    ASSERT_SAME_TYPE(std::wint_t,        decltype(std::fgetwc(fp)));
+    ASSERT_SAME_TYPE(wchar_t*,           decltype(std::fgetws(ws, 0, fp)));
+    ASSERT_SAME_TYPE(std::wint_t,        decltype(std::fputwc(L' ', fp)));
+    ASSERT_SAME_TYPE(int,                decltype(std::fputws(L"", fp)));
+    ASSERT_SAME_TYPE(int,                decltype(std::fwide(fp, 0)));
+    ASSERT_SAME_TYPE(std::wint_t,        decltype(std::getwc(fp)));
+    ASSERT_SAME_TYPE(std::wint_t,        decltype(std::putwc(L' ', fp)));
+    ASSERT_SAME_TYPE(std::wint_t,        decltype(std::ungetwc(L' ', fp)));
+    ASSERT_SAME_TYPE(double,             decltype(std::wcstod(L"", (wchar_t**)0)));
+    ASSERT_SAME_TYPE(float,              decltype(std::wcstof(L"", (wchar_t**)0)));
+    ASSERT_SAME_TYPE(long double,        decltype(std::wcstold(L"", (wchar_t**)0)));
+    ASSERT_SAME_TYPE(long,               decltype(std::wcstol(L"", (wchar_t**)0, 0)));
+    ASSERT_SAME_TYPE(long long,          decltype(std::wcstoll(L"", (wchar_t**)0, 0)));
+    ASSERT_SAME_TYPE(unsigned long,      decltype(std::wcstoul(L"", (wchar_t**)0, 0)));
+    ASSERT_SAME_TYPE(unsigned long long, decltype(std::wcstoull(L"", (wchar_t**)0, 0)));
+    ASSERT_SAME_TYPE(wchar_t*,           decltype(std::wcscpy(ws, L"")));
+    ASSERT_SAME_TYPE(wchar_t*,           decltype(std::wcsncpy(ws, L"", s)));
+    ASSERT_SAME_TYPE(wchar_t*,           decltype(std::wcscat(ws, L"")));
+    ASSERT_SAME_TYPE(wchar_t*,           decltype(std::wcsncat(ws, L"", s)));
+    ASSERT_SAME_TYPE(int,                decltype(std::wcscmp(L"", L"")));
+    ASSERT_SAME_TYPE(int,                decltype(std::wcscoll(L"", L"")));
+    ASSERT_SAME_TYPE(int,                decltype(std::wcsncmp(L"", L"", s)));
+    ASSERT_SAME_TYPE(std::size_t,        decltype(std::wcsxfrm(ws, L"", s)));
+    ASSERT_SAME_TYPE(wchar_t*,           decltype(std::wcschr((wchar_t*)0, L' ')));
+    ASSERT_SAME_TYPE(std::size_t,        decltype(std::wcscspn(L"", L"")));
+    ASSERT_SAME_TYPE(std::size_t,        decltype(std::wcslen(L"")));
+    ASSERT_SAME_TYPE(wchar_t*,           decltype(std::wcspbrk((wchar_t*)0, L"")));
+    ASSERT_SAME_TYPE(wchar_t*,           decltype(std::wcsrchr((wchar_t*)0, L' ')));
+    ASSERT_SAME_TYPE(std::size_t,        decltype(std::wcsspn(L"", L"")));
+    ASSERT_SAME_TYPE(wchar_t*,           decltype(std::wcsstr((wchar_t*)0, L"")));
+    ASSERT_SAME_TYPE(wchar_t*,           decltype(std::wcstok(ws, L"", (wchar_t**)0)));
+    ASSERT_SAME_TYPE(wchar_t*,           decltype(std::wmemchr((wchar_t*)0, L' ', s)));
+    ASSERT_SAME_TYPE(int,                decltype(std::wmemcmp(L"", L"", s)));
+    ASSERT_SAME_TYPE(wchar_t*,           decltype(std::wmemcpy(ws, L"", s)));
+    ASSERT_SAME_TYPE(wchar_t*,           decltype(std::wmemmove(ws, L"", s)));
+    ASSERT_SAME_TYPE(wchar_t*,           decltype(std::wmemset(ws, L' ', s)));
+    ASSERT_SAME_TYPE(std::size_t,        decltype(std::wcsftime(ws, s, L"", tm)));
+    ASSERT_SAME_TYPE(wint_t,             decltype(std::btowc(0)));
+    ASSERT_SAME_TYPE(int,                decltype(std::wctob(w)));
+    ASSERT_SAME_TYPE(int,                decltype(std::mbsinit(&mb)));
+    ASSERT_SAME_TYPE(std::size_t,        decltype(std::mbrlen("", s, &mb)));
+    ASSERT_SAME_TYPE(std::size_t,        decltype(std::mbrtowc(ws, "", s, &mb)));
+    ASSERT_SAME_TYPE(std::size_t,        decltype(std::wcrtomb(ns, L' ', &mb)));
+    ASSERT_SAME_TYPE(std::size_t,        decltype(std::mbsrtowcs(ws, (const char**)0, s, &mb)));
+    ASSERT_SAME_TYPE(std::size_t,        decltype(std::wcsrtombs(ns, (const wchar_t**)0, s, &mb)));
 
     // These tests fail on systems whose C library doesn't provide a correct overload
     // set for wcschr, wcspbrk, wcsrchr, wcsstr, and wmemchr, unless the compiler is
     // a suitably recent version of Clang.
 #if !defined(__APPLE__) || defined(_LIBCPP_PREFERRED_OVERLOAD)
-    static_assert((std::is_same<decltype(std::wcschr((const wchar_t*)0, L' ')), const wchar_t*>::value), "");
-    static_assert((std::is_same<decltype(std::wcspbrk((const wchar_t*)0, L"")), const wchar_t*>::value), "");
-    static_assert((std::is_same<decltype(std::wcsrchr((const wchar_t*)0, L' ')), const wchar_t*>::value), "");
-    static_assert((std::is_same<decltype(std::wcsstr((const wchar_t*)0, L"")), const wchar_t*>::value), "");
-    static_assert((std::is_same<decltype(std::wmemchr((const wchar_t*)0, L' ', s)), const wchar_t*>::value), "");
+    ASSERT_SAME_TYPE(const wchar_t*,     decltype(std::wcschr((const wchar_t*)0, L' ')));
+    ASSERT_SAME_TYPE(const wchar_t*,     decltype(std::wcspbrk((const wchar_t*)0, L"")));
+    ASSERT_SAME_TYPE(const wchar_t*,     decltype(std::wcsrchr((const wchar_t*)0, L' ')));
+    ASSERT_SAME_TYPE(const wchar_t*,     decltype(std::wcsstr((const wchar_t*)0, L"")));
+    ASSERT_SAME_TYPE(const wchar_t*,     decltype(std::wmemchr((const wchar_t*)0, L' ', s)));
 #endif
 
 #ifndef _LIBCPP_HAS_NO_STDIN
-    static_assert((std::is_same<decltype(std::getwchar()), std::wint_t>::value), "");
-    static_assert((std::is_same<decltype(std::vwscanf(L"", va)), int>::value), "");
-    static_assert((std::is_same<decltype(std::wscanf(L"")), int>::value), "");
+    ASSERT_SAME_TYPE(std::wint_t,        decltype(std::getwchar()));
+    ASSERT_SAME_TYPE(int,                decltype(std::vwscanf(L"", va)));
+    ASSERT_SAME_TYPE(int,                decltype(std::wscanf(L"")));
 #endif
 
 #ifndef _LIBCPP_HAS_NO_STDOUT
-    static_assert((std::is_same<decltype(std::putwchar(L' ')), std::wint_t>::value), "");
-    static_assert((std::is_same<decltype(std::vwprintf(L"", va)), int>::value), "");
-    static_assert((std::is_same<decltype(std::wprintf(L"")), int>::value), "");
+    ASSERT_SAME_TYPE(std::wint_t,        decltype(std::putwchar(L' ')));
+    ASSERT_SAME_TYPE(int,                decltype(std::vwprintf(L"", va)));
+    ASSERT_SAME_TYPE(int,                decltype(std::wprintf(L"")));
 #endif
 }

Modified: libcxx/trunk/test/std/strings/c.strings/cwctype.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/strings/c.strings/cwctype.pass.cpp?rev=349522&r1=349521&r2=349522&view=diff
==============================================================================
--- libcxx/trunk/test/std/strings/c.strings/cwctype.pass.cpp (original)
+++ libcxx/trunk/test/std/strings/c.strings/cwctype.pass.cpp Tue Dec 18 11:07:30 2018
@@ -12,6 +12,9 @@
 #include <cwctype>
 #include <type_traits>
 
+#include "test_macros.h"
+
+
 #ifndef WEOF
 #error WEOF not defined
 #endif
@@ -91,24 +94,24 @@
 int main()
 {
     std::wint_t w = 0;
-    std::wctrans_t wctr = 0;
-    std::wctype_t wct = 0;
-    static_assert((std::is_same<decltype(std::iswalnum(w)), int>::value), "");
-    static_assert((std::is_same<decltype(std::iswalpha(w)), int>::value), "");
-    static_assert((std::is_same<decltype(std::iswblank(w)), int>::value), "");
-    static_assert((std::is_same<decltype(std::iswcntrl(w)), int>::value), "");
-    static_assert((std::is_same<decltype(std::iswdigit(w)), int>::value), "");
-    static_assert((std::is_same<decltype(std::iswgraph(w)), int>::value), "");
-    static_assert((std::is_same<decltype(std::iswlower(w)), int>::value), "");
-    static_assert((std::is_same<decltype(std::iswprint(w)), int>::value), "");
-    static_assert((std::is_same<decltype(std::iswpunct(w)), int>::value), "");
-    static_assert((std::is_same<decltype(std::iswspace(w)), int>::value), "");
-    static_assert((std::is_same<decltype(std::iswupper(w)), int>::value), "");
-    static_assert((std::is_same<decltype(std::iswxdigit(w)), int>::value), "");
-    static_assert((std::is_same<decltype(std::iswctype(w, wct)), int>::value), "");
-    static_assert((std::is_same<decltype(std::wctype("")), std::wctype_t>::value), "");
-    static_assert((std::is_same<decltype(std::towlower(w)), std::wint_t>::value), "");
-    static_assert((std::is_same<decltype(std::towupper(w)), std::wint_t>::value), "");
-    static_assert((std::is_same<decltype(std::towctrans(w, wctr)), std::wint_t>::value), "");
-    static_assert((std::is_same<decltype(std::wctrans("")), std::wctrans_t>::value), "");
+    ASSERT_SAME_TYPE(int, decltype(std::iswalnum(w)));
+    ASSERT_SAME_TYPE(int, decltype(std::iswalpha(w)));
+    ASSERT_SAME_TYPE(int, decltype(std::iswblank(w)));
+    ASSERT_SAME_TYPE(int, decltype(std::iswcntrl(w)));
+    ASSERT_SAME_TYPE(int, decltype(std::iswdigit(w)));
+    ASSERT_SAME_TYPE(int, decltype(std::iswgraph(w)));
+    ASSERT_SAME_TYPE(int, decltype(std::iswlower(w)));
+    ASSERT_SAME_TYPE(int, decltype(std::iswprint(w)));
+    ASSERT_SAME_TYPE(int, decltype(std::iswpunct(w)));
+    ASSERT_SAME_TYPE(int, decltype(std::iswspace(w)));
+    ASSERT_SAME_TYPE(int, decltype(std::iswupper(w)));
+    ASSERT_SAME_TYPE(int, decltype(std::iswxdigit(w)));
+
+    ASSERT_SAME_TYPE(int, decltype(std::iswctype(w, std::wctype_t())));
+    
+    ASSERT_SAME_TYPE(std::wctype_t,  decltype(std::wctype("")));
+    ASSERT_SAME_TYPE(std::wint_t,    decltype(std::towlower(w)));
+    ASSERT_SAME_TYPE(std::wint_t,    decltype(std::towupper(w)));
+    ASSERT_SAME_TYPE(std::wint_t,    decltype(std::towctrans(w, std::wctrans_t())));
+    ASSERT_SAME_TYPE(std::wctrans_t, decltype(std::wctrans("")));
 }




More information about the libcxx-commits mailing list