1 | //===-- Unittests for toascii----------------------------------------------===// |
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 "src/ctype/toascii.h" |
10 | |
11 | #include "test/UnitTest/Test.h" |
12 | |
13 | TEST(LlvmLibcToAscii, DefaultLocale) { |
14 | // Loops through all characters, verifying that ascii characters |
15 | // (which are all 7 bit unsigned integers) |
16 | // return themself, and that all other characters return themself |
17 | // mod 128 (which is equivalent to & 0x7f) |
18 | for (int ch = -255; ch < 255; ++ch) { |
19 | if (0 <= ch && ch <= 0x7f) |
20 | EXPECT_EQ(LIBC_NAMESPACE::toascii(ch), ch); |
21 | else |
22 | EXPECT_EQ(LIBC_NAMESPACE::toascii(ch), ch & 0x7f); |
23 | } |
24 | } |
25 | |