]> Savannah Git Hosting - gnulib.git/commitdiff
uniwbrk: Add unit tests of CR-LF sequences.
authorBruno Haible <bruno@clisp.org>
Wed, 29 Dec 2021 11:15:37 +0000 (12:15 +0100)
committerBruno Haible <bruno@clisp.org>
Wed, 29 Dec 2021 11:15:37 +0000 (12:15 +0100)
* tests/uniwbrk/test-u8-wordbreaks.c (main): Add test of a string with
CR-LF.
* tests/uniwbrk/test-u16-wordbreaks.c (main): Likewise.
* tests/uniwbrk/test-u32-wordbreaks.c (main): Likewise.

ChangeLog
tests/uniwbrk/test-u16-wordbreaks.c
tests/uniwbrk/test-u32-wordbreaks.c
tests/uniwbrk/test-u8-wordbreaks.c

index a1c922d16a76a3774b6183caef99dcd33cf09fb6..06ace37069ebeca03024eccd66f54b4e4ee404c0 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2021-12-29  Bruno Haible  <bruno@clisp.org>
+
+       uniwbrk: Add unit tests of CR-LF sequences.
+       * tests/uniwbrk/test-u8-wordbreaks.c (main): Add test of a string with
+       CR-LF.
+       * tests/uniwbrk/test-u16-wordbreaks.c (main): Likewise.
+       * tests/uniwbrk/test-u32-wordbreaks.c (main): Likewise.
+
 2021-12-29  Bruno Haible  <bruno@clisp.org>
 
        unigbrk: Add unit tests of CR-LF sequences.
index eb6b13c61a417e153665850dd4a687e858371595..734c8049bea1992642045225aa139a8ef6d7c4bb 100644 (file)
@@ -90,6 +90,23 @@ main ()
     free (p);
   }
 
+  /* CR LF handling.  */
+  {
+    static const uint16_t input[8] =
+      { 'a', '\n', 'b', '\r', 'c', '\r', '\n', 'd' };
+    char *p = (char *) malloc (SIZEOF (input));
+    size_t i;
+
+    u16_wordbreaks (input, SIZEOF (input), p);
+    for (i = 0; i < 8; i++)
+      {
+        ASSERT (p[i] == (i == 1 || i == 2 || i == 3 || i == 4 || i == 5
+                         || i == 7 ? 1 :
+                         0));
+      }
+    free (p);
+  }
+
   /* Test regional indicators.  */
   {
     static const uint16_t input[10] =
index 5855486ff6eb6c4b553f2afc3af36447ecc369bc..7b106ac0cc88e991bb656b7a300b2525890535aa 100644 (file)
@@ -90,6 +90,23 @@ main ()
     free (p);
   }
 
+  /* CR LF handling.  */
+  {
+    static const uint32_t input[8] =
+      { 'a', '\n', 'b', '\r', 'c', '\r', '\n', 'd' };
+    char *p = (char *) malloc (SIZEOF (input));
+    size_t i;
+
+    u32_wordbreaks (input, SIZEOF (input), p);
+    for (i = 0; i < 8; i++)
+      {
+        ASSERT (p[i] == (i == 1 || i == 2 || i == 3 || i == 4 || i == 5
+                         || i == 7 ? 1 :
+                         0));
+      }
+    free (p);
+  }
+
   /* Test regional indicators.  */
   {
     static const uint32_t input[6] =
index 2c36840ba8baf3fb31ede2af7ac38f18a40dfd4f..5cf9d17168f06f3220b59465a18a437a3769d582 100644 (file)
@@ -81,6 +81,22 @@ main ()
     free (p);
   }
 
+  /* CR LF handling.  */
+  {
+    static const uint8_t input[8] = "a\nb\rc\r\nd";
+    char *p = (char *) malloc (SIZEOF (input));
+    size_t i;
+
+    u8_wordbreaks (input, SIZEOF (input), p);
+    for (i = 0; i < 8; i++)
+      {
+        ASSERT (p[i] == (i == 1 || i == 2 || i == 3 || i == 4 || i == 5
+                         || i == 7 ? 1 :
+                         0));
+      }
+    free (p);
+  }
+
   /* Test regional indicators.  */
   {
     static const uint8_t input[18] =