| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| add_libc_testsuite(libc_wchar_unittests) | ||
|
|
||
| add_libc_unittest( | ||
| btowc_test | ||
| SUITE | ||
| libc_wchar_unittests | ||
| SRCS | ||
| btowc_test.cpp | ||
| DEPENDS | ||
| libc.src.wchar.btowc | ||
| ) | ||
|
|
||
| add_libc_unittest( | ||
| wctob_test | ||
| SUITE | ||
| libc_wchar_unittests | ||
| SRCS | ||
| wctob_test.cpp | ||
| DEPENDS | ||
| libc.src.wchar.wctob | ||
| ) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| //===-- Unittests for btowc ---------------------------------------------===// | ||
| // | ||
| // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| // See https://llvm.org/LICENSE.txt for license information. | ||
| // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| #include <wchar.h> //for WEOF | ||
|
|
||
| #include "src/wchar/btowc.h" | ||
|
|
||
| #include "test/UnitTest/Test.h" | ||
|
|
||
| TEST(LlvmLibcBtowc, DefaultLocale) { | ||
| // Loops through all characters, verifying that ascii returns itself and | ||
| // everything else returns WEOF. | ||
| for (int c = 0; c < 255; ++c) { | ||
| if (c < 128) | ||
| EXPECT_EQ(__llvm_libc::btowc(c), static_cast<wint_t>(c)); | ||
| else | ||
| EXPECT_EQ(__llvm_libc::btowc(c), WEOF); | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| //===-- Unittests for wctob ---------------------------------------------===// | ||
| // | ||
| // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| // See https://llvm.org/LICENSE.txt for license information. | ||
| // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| #include <stdio.h> //for EOF | ||
|
|
||
| #include "src/wchar/wctob.h" | ||
|
|
||
| #include "test/UnitTest/Test.h" | ||
|
|
||
| TEST(LlvmLibcWctob, DefaultLocale) { | ||
| // Loops through a subset of the wide characters, verifying that ascii returns | ||
| // itself and everything else returns EOF. | ||
| for (wint_t c = 0; c < 32767; ++c) { | ||
| if (c < 128) | ||
| EXPECT_EQ(__llvm_libc::wctob(c), static_cast<int>(c)); | ||
| else | ||
| EXPECT_EQ(__llvm_libc::wctob(c), EOF); | ||
| } | ||
| } |