]> Savannah Git Hosting - gnulib.git/commitdiff
unictype/category-and-not: Add more tests.
authorBruno Haible <bruno@clisp.org>
Wed, 11 Oct 2023 14:43:07 +0000 (16:43 +0200)
committerBruno Haible <bruno@clisp.org>
Wed, 11 Oct 2023 14:43:07 +0000 (16:43 +0200)
Suggested by Arindam Sharma <arindam.sharma@imperial.ac.uk>.

* tests/unictype/test-categ_and_not.c (main): Add two more test cases.
* modules/unictype/category-and-not-tests (Depends-on): Add
unictype/category-Cc.

ChangeLog
modules/unictype/category-and-not-tests
tests/unictype/test-categ_and_not.c

index ef036d1585f02a99726035fb3a60f473d591b60a..22205096a3563d799aea58005def9a56fabe56ad 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2023-10-11  Bruno Haible  <bruno@clisp.org>
+
+       unictype/category-and-not: Add more tests.
+       Suggested by Arindam Sharma <arindam.sharma@imperial.ac.uk>.
+       * tests/unictype/test-categ_and_not.c (main): Add two more test cases.
+       * modules/unictype/category-and-not-tests (Depends-on): Add
+       unictype/category-Cc.
+
 2023-10-09  Bruno Haible  <bruno@clisp.org>
 
        tests: Refactor functions for signalling NaNs.
index ba1edb873f01bdbbf98db7538fc7b30c2583da1b..5021ae9eb33e08a56b23e081ff2f9b6b261f9450 100644 (file)
@@ -9,6 +9,7 @@ unictype/category-L
 unictype/category-N
 unictype/category-Lu
 unictype/category-Nd
+unictype/category-Cc
 
 configure.ac:
 
index 74c75aee5ff1b5d080d9cd989c8341f2d6b280e4..1a49cd0e14d61ec2314741a9ec801d73d0e1ad64 100644 (file)
 int
 main ()
 {
-  uc_general_category_t ct =
-    uc_general_category_and_not (
-      uc_general_category_or (UC_LETTER, UC_NUMBER),
-      uc_general_category_or (UC_UPPERCASE_LETTER, UC_DECIMAL_DIGIT_NUMBER));
-
-  ASSERT (!uc_is_general_category ('A', ct));
-  ASSERT (uc_is_general_category ('a', ct));
-  ASSERT (!uc_is_general_category ('7', ct));
-  ASSERT (uc_is_general_category (0x00B2, ct));
+  { /* A case where the result's bit mask is 0.  */
+    uc_general_category_t ct =
+      uc_general_category_and_not (UC_UPPERCASE_LETTER, UC_LETTER);
+
+    ASSERT (!uc_is_general_category ('A', ct));
+    ASSERT (!uc_is_general_category ('a', ct));
+  }
+  { /* A case where the result's bit mask is the same as the first argument.  */
+    uc_general_category_t ct =
+      uc_general_category_and_not (
+        uc_general_category_or (UC_LETTER, UC_NUMBER),
+        UC_CONTROL);
+
+    ASSERT (uc_is_general_category ('A', ct));
+    ASSERT (uc_is_general_category ('a', ct));
+    ASSERT (uc_is_general_category ('7', ct));
+    ASSERT (uc_is_general_category (0x00B2, ct));
+  }
+  { /* The general case, where the result's bit mask is neither 0 nor the first
+       argument.  */
+    uc_general_category_t ct =
+      uc_general_category_and_not (
+        uc_general_category_or (UC_LETTER, UC_NUMBER),
+        uc_general_category_or (UC_UPPERCASE_LETTER, UC_DECIMAL_DIGIT_NUMBER));
+
+    ASSERT (!uc_is_general_category ('A', ct));
+    ASSERT (uc_is_general_category ('a', ct));
+    ASSERT (!uc_is_general_category ('7', ct));
+    ASSERT (uc_is_general_category (0x00B2, ct));
+  }
 
   return 0;
 }