diff options
Diffstat (limited to 'libcxx/test/std/strings/c.strings')
10 files changed, 499 insertions, 0 deletions
diff --git a/libcxx/test/std/strings/c.strings/cctype.pass.cpp b/libcxx/test/std/strings/c.strings/cctype.pass.cpp new file mode 100644 index 00000000000..867338fb09c --- /dev/null +++ b/libcxx/test/std/strings/c.strings/cctype.pass.cpp @@ -0,0 +1,103 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <cctype> + +#include <cctype> +#include <type_traits> +#include <cassert> + +#ifdef isalnum +#error isalnum defined +#endif + +#ifdef isalpha +#error isalpha defined +#endif + +#ifdef isblank +#error isblank defined +#endif + +#ifdef iscntrl +#error iscntrl defined +#endif + +#ifdef isdigit +#error isdigit defined +#endif + +#ifdef isgraph +#error isgraph defined +#endif + +#ifdef islower +#error islower defined +#endif + +#ifdef isprint +#error isprint defined +#endif + +#ifdef ispunct +#error ispunct defined +#endif + +#ifdef isspace +#error isspace defined +#endif + +#ifdef isupper +#error isupper defined +#endif + +#ifdef isxdigit +#error isxdigit defined +#endif + +#ifdef tolower +#error tolower defined +#endif + +#ifdef toupper +#error toupper defined +#endif + +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(isalnum('a')); + assert(isalpha('a')); + assert(isblank(' ')); + assert(!iscntrl(' ')); + assert(!isdigit('a')); + assert(isgraph('a')); + assert(islower('a')); + assert(isprint('a')); + assert(!ispunct('a')); + assert(!isspace('a')); + assert(!isupper('a')); + assert(isxdigit('a')); + assert(tolower('A') == 'a'); + assert(toupper('a') == 'A'); +} diff --git a/libcxx/test/std/strings/c.strings/cstring.pass.cpp b/libcxx/test/std/strings/c.strings/cstring.pass.cpp new file mode 100644 index 00000000000..5ed7e6cd11a --- /dev/null +++ b/libcxx/test/std/strings/c.strings/cstring.pass.cpp @@ -0,0 +1,53 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <cstring> + +#include <cstring> +#include <type_traits> + +#ifndef NULL +#error NULL not defined +#endif + +int main() +{ + std::size_t s = 0; + void* vp = 0; + 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(vpc, 0, s)), const void*>::value), ""); + static_assert((std::is_same<decltype(std::memchr(vp, 0, s)), void*>::value), ""); +// static_assert((std::is_same<decltype(std::strchr(cpc, 0)), const char*>::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(cpc, cpc)), const char*>::value), ""); + static_assert((std::is_same<decltype(std::strpbrk(cp, cpc)), char*>::value), ""); +// static_assert((std::is_same<decltype(std::strrchr(cpc, 0)), const 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(cpc, cpc)), const char*>::value), ""); + static_assert((std::is_same<decltype(std::strstr(cp, cpc)), char*>::value), ""); + static_assert((std::is_same<decltype(std::strtok(cp, cpc)), char*>::value), ""); + 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), ""); +} diff --git a/libcxx/test/std/strings/c.strings/cuchar.pass.cpp b/libcxx/test/std/strings/c.strings/cuchar.pass.cpp new file mode 100644 index 00000000000..022c656e8a2 --- /dev/null +++ b/libcxx/test/std/strings/c.strings/cuchar.pass.cpp @@ -0,0 +1,18 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// XFAIL: * + +// <cuchar> + +#include <cuchar> + +int main() +{ +} diff --git a/libcxx/test/std/strings/c.strings/cwchar.pass.cpp b/libcxx/test/std/strings/c.strings/cwchar.pass.cpp new file mode 100644 index 00000000000..d0481b70610 --- /dev/null +++ b/libcxx/test/std/strings/c.strings/cwchar.pass.cpp @@ -0,0 +1,109 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <cwchar> + +#include <cwchar> +#include <type_traits> + +#ifndef NULL +#error NULL not defined +#endif + +#ifndef WCHAR_MAX +#error WCHAR_MAX not defined +#endif + +#ifndef WCHAR_MIN +#error WCHAR_MIN not defined +#endif + +#ifndef WEOF +#error WEOF not defined +#endif + +int main() +{ + std::mbstate_t mb = {0}; + std::size_t s = 0; + std::tm *tm = 0; + std::wint_t w = 0; + ::FILE* fp = 0; +#ifdef __APPLE__ + __darwin_va_list va; +#else + __builtin_va_list va; +#endif + char* ns = 0; + wchar_t* ws = 0; + 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::vwprintf(L"", va)), int>::value), ""); + static_assert((std::is_same<decltype(std::vwscanf(L"", va)), int>::value), ""); + static_assert((std::is_same<decltype(std::wprintf(L"")), int>::value), ""); + static_assert((std::is_same<decltype(std::wscanf(L"")), 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::getwchar()), 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::putwchar(L' ')), 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((const wchar_t*)0, L' ')), const wchar_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((const wchar_t*)0, L"")), const wchar_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((const wchar_t*)0, L' ')), const 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((const wchar_t*)0, L"")), const wchar_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((const wchar_t*)0, L' ', s)), const 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), ""); +} diff --git a/libcxx/test/std/strings/c.strings/cwctype.pass.cpp b/libcxx/test/std/strings/c.strings/cwctype.pass.cpp new file mode 100644 index 00000000000..6d66415abdc --- /dev/null +++ b/libcxx/test/std/strings/c.strings/cwctype.pass.cpp @@ -0,0 +1,114 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <cwctype> + +#include <cwctype> +#include <type_traits> + +#ifndef WEOF +#error WEOF not defined +#endif + +#ifdef iswalnum +#error iswalnum defined +#endif + +#ifdef iswalpha +#error iswalpha defined +#endif + +#ifdef iswblank +#error iswblank defined +#endif + +#ifdef iswcntrl +#error iswcntrl defined +#endif + +#ifdef iswdigit +#error iswdigit defined +#endif + +#ifdef iswgraph +#error iswgraph defined +#endif + +#ifdef iswlower +#error iswlower defined +#endif + +#ifdef iswprint +#error iswprint defined +#endif + +#ifdef iswpunct +#error iswpunct defined +#endif + +#ifdef iswspace +#error iswspace defined +#endif + +#ifdef iswupper +#error iswupper defined +#endif + +#ifdef iswxdigit +#error iswxdigit defined +#endif + +#ifdef iswctype +#error iswctype defined +#endif + +#ifdef wctype +#error wctype defined +#endif + +#ifdef towlower +#error towlower defined +#endif + +#ifdef towupper +#error towupper defined +#endif + +#ifdef towctrans +#error towctrans defined +#endif + +#ifdef wctrans +#error wctrans defined +#endif + +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), ""); +} diff --git a/libcxx/test/std/strings/c.strings/version_cctype.pass.cpp b/libcxx/test/std/strings/c.strings/version_cctype.pass.cpp new file mode 100644 index 00000000000..e0919d9d27b --- /dev/null +++ b/libcxx/test/std/strings/c.strings/version_cctype.pass.cpp @@ -0,0 +1,20 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <cctype> + +#include <cctype> + +#ifndef _LIBCPP_VERSION +#error _LIBCPP_VERSION not defined +#endif + +int main() +{ +} diff --git a/libcxx/test/std/strings/c.strings/version_cstring.pass.cpp b/libcxx/test/std/strings/c.strings/version_cstring.pass.cpp new file mode 100644 index 00000000000..87e705aec4c --- /dev/null +++ b/libcxx/test/std/strings/c.strings/version_cstring.pass.cpp @@ -0,0 +1,20 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <cstring> + +#include <cstring> + +#ifndef _LIBCPP_VERSION +#error _LIBCPP_VERSION not defined +#endif + +int main() +{ +} diff --git a/libcxx/test/std/strings/c.strings/version_cuchar.pass.cpp b/libcxx/test/std/strings/c.strings/version_cuchar.pass.cpp new file mode 100644 index 00000000000..dcfdcc37ac7 --- /dev/null +++ b/libcxx/test/std/strings/c.strings/version_cuchar.pass.cpp @@ -0,0 +1,22 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// XFAIL: * + +// <cuchar> + +#include <cuchar> + +#ifndef _LIBCPP_VERSION +#error _LIBCPP_VERSION not defined +#endif + +int main() +{ +} diff --git a/libcxx/test/std/strings/c.strings/version_cwchar.pass.cpp b/libcxx/test/std/strings/c.strings/version_cwchar.pass.cpp new file mode 100644 index 00000000000..72e9855c54e --- /dev/null +++ b/libcxx/test/std/strings/c.strings/version_cwchar.pass.cpp @@ -0,0 +1,20 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <cwchar> + +#include <cwchar> + +#ifndef _LIBCPP_VERSION +#error _LIBCPP_VERSION not defined +#endif + +int main() +{ +} diff --git a/libcxx/test/std/strings/c.strings/version_cwctype.pass.cpp b/libcxx/test/std/strings/c.strings/version_cwctype.pass.cpp new file mode 100644 index 00000000000..461482abe76 --- /dev/null +++ b/libcxx/test/std/strings/c.strings/version_cwctype.pass.cpp @@ -0,0 +1,20 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <cwctype> + +#include <cwctype> + +#ifndef _LIBCPP_VERSION +#error _LIBCPP_VERSION not defined +#endif + +int main() +{ +} |