xref: /llvm-project/libc/test/src/wchar/wctob_test.cpp (revision c63112a9118277a20ae440f3f69189c0937e8f4d)
146b50872SMichael Jones //===-- Unittests for wctob ---------------------------------------------===//
246b50872SMichael Jones //
346b50872SMichael Jones // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
446b50872SMichael Jones // See https://llvm.org/LICENSE.txt for license information.
546b50872SMichael Jones // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
646b50872SMichael Jones //
746b50872SMichael Jones //===----------------------------------------------------------------------===//
846b50872SMichael Jones 
9*c63112a9Slntue #include "hdr/stdio_macros.h" //for EOF
1046b50872SMichael Jones #include "src/wchar/wctob.h"
1146b50872SMichael Jones #include "test/UnitTest/Test.h"
1246b50872SMichael Jones 
1346b50872SMichael Jones TEST(LlvmLibcWctob, DefaultLocale) {
1446b50872SMichael Jones   // Loops through a subset of the wide characters, verifying that ascii returns
1546b50872SMichael Jones   // itself and everything else returns EOF.
1646b50872SMichael Jones   for (wint_t c = 0; c < 32767; ++c) {
1746b50872SMichael Jones     if (c < 128)
18b6bc9d72SGuillaume Chatelet       EXPECT_EQ(LIBC_NAMESPACE::wctob(c), static_cast<int>(c));
1946b50872SMichael Jones     else
20b6bc9d72SGuillaume Chatelet       EXPECT_EQ(LIBC_NAMESPACE::wctob(c), EOF);
2146b50872SMichael Jones   }
2246b50872SMichael Jones }
23