summaryrefslogtreecommitdiff
path: root/libc/test/src/wchar/wctob_test.cpp
blob: 7a8d6eea0c82a09a80826098731a173ce2ee3f00 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
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);
  }
}