146b50872SMichael Jones //===-- Unittests for btowc ---------------------------------------------===// 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*95d4c97aSlntue #include "hdr/wchar_macros.h" // for WEOF 1046b50872SMichael Jones #include "src/wchar/btowc.h" 1146b50872SMichael Jones #include "test/UnitTest/Test.h" 1246b50872SMichael Jones 1346b50872SMichael Jones TEST(LlvmLibcBtowc, DefaultLocale) { 1446b50872SMichael Jones // Loops through all characters, verifying that ascii returns itself and 1546b50872SMichael Jones // everything else returns WEOF. 1646b50872SMichael Jones for (int c = 0; c < 255; ++c) { 1746b50872SMichael Jones if (c < 128) 18b6bc9d72SGuillaume Chatelet EXPECT_EQ(LIBC_NAMESPACE::btowc(c), static_cast<wint_t>(c)); 1946b50872SMichael Jones else 20b6bc9d72SGuillaume Chatelet EXPECT_EQ(LIBC_NAMESPACE::btowc(c), WEOF); 2146b50872SMichael Jones } 2246b50872SMichael Jones } 23