aboutsummaryrefslogtreecommitdiff
path: root/libc/test/src/ctype/isspace_test.cpp
blob: 6e11919100ec98430350b557525954588e873df0 (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
25
26
27
28
//===-- Unittests for isspace----------------------------------------------===//
//
// 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 "src/ctype/isspace.h"
#include "test/UnitTest/Test.h"

TEST(LlvmLibcIsSpace, DefaultLocale) {
  // Loops through all characters, verifying that space characters
  // return true and everything else returns false.
  // Hexadecimal | Symbol
  // ---------------------------
  //    0x09     |   horizontal tab
  //    0x0a     |   line feed
  //    0x0b     |   vertical tab
  //    0x0d     |   carriage return
  //    0x20     |   space
  for (int ch = -255; ch < 255; ++ch) {
    if (ch == 0x20 || (0x09 <= ch && ch <= 0x0d))
      EXPECT_NE(LIBC_NAMESPACE::isspace(ch), 0);
    else
      EXPECT_EQ(LIBC_NAMESPACE::isspace(ch), 0);
  }
}