| 1 | //===-- Unittests for wctob ---------------------------------------------===// |
| 2 | // |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 4 | // See https://llvm.org/LICENSE.txt for license information. |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 6 | // |
| 7 | //===----------------------------------------------------------------------===// |
| 8 | |
| 9 | #include "hdr/stdio_macros.h" //for EOF |
| 10 | #include "src/wchar/wctob.h" |
| 11 | #include "test/UnitTest/Test.h" |
| 12 | |
| 13 | TEST(LlvmLibcWctob, DefaultLocale) { |
| 14 | // Loops through a subset of the wide characters, verifying that ascii returns |
| 15 | // itself and everything else returns EOF. |
| 16 | for (wint_t c = 0; c < 32767; ++c) { |
| 17 | if (c < 128) |
| 18 | EXPECT_EQ(LIBC_NAMESPACE::wctob(c), static_cast<int>(c)); |
| 19 | else |
| 20 | EXPECT_EQ(LIBC_NAMESPACE::wctob(c), EOF); |
| 21 | } |
| 22 | } |
| 23 | |