aboutsummaryrefslogtreecommitdiff
path: root/libc/test/src/ctype/isspace_test.cpp
blob: e1caded674525417c8c1de62087f3f4983ee2be6 (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 "utils/UnitTest/Test.h"

TEST(IsSpace, 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 = 0; ch < 255; ++ch) {
    if (ch == 0x20 || (0x09 <= ch && ch <= 0x0d))
      EXPECT_NE(__llvm_libc::isspace(ch), 0);
    else
      EXPECT_EQ(__llvm_libc::isspace(ch), 0);
  }
}