summaryrefslogtreecommitdiff
path: root/Tests
diff options
context:
space:
mode:
authorTim Schumacher <timschumi@gmx.de>2021-09-17 18:12:27 +0200
committerBrian Gianforcaro <b.gianfo@gmail.com>2021-09-17 22:59:51 +0000
commit7b17230d7aec439f2015391099802cfdcdf7cd61 (patch)
treed066b4421819a056ae2db4df2d5cc51db38d38bd /Tests
parentac406c8d0ea0d701fdafe84d33e293e250045e0a (diff)
downloadserenity-7b17230d7aec439f2015391099802cfdcdf7cd61.zip
LibC: Implement wctype
Diffstat (limited to 'Tests')
-rw-r--r--Tests/LibC/CMakeLists.txt1
-rw-r--r--Tests/LibC/TestWctype.cpp30
2 files changed, 31 insertions, 0 deletions
diff --git a/Tests/LibC/CMakeLists.txt b/Tests/LibC/CMakeLists.txt
index daec9dae63..ca4570358d 100644
--- a/Tests/LibC/CMakeLists.txt
+++ b/Tests/LibC/CMakeLists.txt
@@ -15,6 +15,7 @@ set(TEST_SOURCES
TestStackSmash.cpp
TestStrlcpy.cpp
TestStrtodAccuracy.cpp
+ TestWctype.cpp
)
set_source_files_properties(TestStrtodAccuracy.cpp PROPERTIES COMPILE_FLAGS "-fno-builtin-strtod")
diff --git a/Tests/LibC/TestWctype.cpp b/Tests/LibC/TestWctype.cpp
new file mode 100644
index 0000000000..190d152f6d
--- /dev/null
+++ b/Tests/LibC/TestWctype.cpp
@@ -0,0 +1,30 @@
+/*
+ * Copyright (c) 2021, the SerenityOS developers
+ *
+ * SPDX-License-Identifier: BSD-2-Clause
+ */
+
+#include <LibTest/TestCase.h>
+
+#include <wctype.h>
+
+TEST_CASE(wctype)
+{
+ // Test that existing properties return non-zero wctypes.
+ EXPECT(wctype("alnum") != 0);
+ EXPECT(wctype("alpha") != 0);
+ EXPECT(wctype("blank") != 0);
+ EXPECT(wctype("cntrl") != 0);
+ EXPECT(wctype("digit") != 0);
+ EXPECT(wctype("graph") != 0);
+ EXPECT(wctype("lower") != 0);
+ EXPECT(wctype("print") != 0);
+ EXPECT(wctype("punct") != 0);
+ EXPECT(wctype("space") != 0);
+ EXPECT(wctype("upper") != 0);
+ EXPECT(wctype("xdigit") != 0);
+
+ // Test that invalid properties return the "invalid" wctype (0).
+ EXPECT(wctype("") == 0);
+ EXPECT(wctype("abc") == 0);
+}