]> Savannah Git Hosting - gnulib.git/commitdiff
mbsrtowcs tests: Renumber tests.
authorBruno Haible <bruno@clisp.org>
Sat, 29 Jul 2023 22:25:57 +0000 (00:25 +0200)
committerBruno Haible <bruno@clisp.org>
Sat, 29 Jul 2023 23:41:30 +0000 (01:41 +0200)
* tests/test-mbsrtowcs*.sh: Renamed 1 -> 2 -> 3 -> 4 -> 5 -> 1.
* tests/test-mbsrtowcs.c: Update.
* modules/mbsrtowcs-tests: Update.

13 files changed:
ChangeLog
modules/mbsrtowcs-tests
tests/test-mbsrtowcs-1.sh [new file with mode: 0755]
tests/test-mbsrtowcs-2.sh [new file with mode: 0755]
tests/test-mbsrtowcs-3.sh [new file with mode: 0755]
tests/test-mbsrtowcs-4.sh [new file with mode: 0755]
tests/test-mbsrtowcs-5.sh [new file with mode: 0755]
tests/test-mbsrtowcs.c
tests/test-mbsrtowcs1.sh [deleted file]
tests/test-mbsrtowcs2.sh [deleted file]
tests/test-mbsrtowcs3.sh [deleted file]
tests/test-mbsrtowcs4.sh [deleted file]
tests/test-mbsrtowcs5.sh [deleted file]

index 89cbd4cfd95bde3cff7970fda98f7db2a4e4843e..4d450df4a097b0058d850a1ed0346dfa40f2aa94 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
 2023-07-29  Bruno Haible  <bruno@clisp.org>
 
+       mbsrtowcs tests: Renumber tests.
+       * tests/test-mbsrtowcs*.sh: Renamed 1 -> 2 -> 3 -> 4 -> 5 -> 1.
+       * tests/test-mbsrtowcs.c: Update.
+       * modules/mbsrtowcs-tests: Update.
+
        mbsnrtowcs tests: Renumber tests.
        * tests/test-mbsnrtowcs*.sh: Renamed 1 -> 2 -> 3 -> 4 -> 5 -> 1.
        * tests/test-mbsnrtowcs.c: Update.
index 36050c670d6473572d4c96484c3f4db5b8324ca5..ec7c5c9f6afa358c8d1801f79da756f22c60dcb2 100644 (file)
@@ -1,9 +1,9 @@
 Files:
-tests/test-mbsrtowcs1.sh
-tests/test-mbsrtowcs2.sh
-tests/test-mbsrtowcs3.sh
-tests/test-mbsrtowcs4.sh
-tests/test-mbsrtowcs5.sh
+tests/test-mbsrtowcs-1.sh
+tests/test-mbsrtowcs-2.sh
+tests/test-mbsrtowcs-3.sh
+tests/test-mbsrtowcs-4.sh
+tests/test-mbsrtowcs-5.sh
 tests/test-mbsrtowcs.c
 tests/signature.h
 tests/macros.h
@@ -26,8 +26,8 @@ gt_LOCALE_ZH_CN
 
 Makefile.am:
 TESTS += \
-  test-mbsrtowcs1.sh test-mbsrtowcs2.sh test-mbsrtowcs3.sh test-mbsrtowcs4.sh \
-  test-mbsrtowcs5.sh
+  test-mbsrtowcs-1.sh test-mbsrtowcs-2.sh test-mbsrtowcs-3.sh \
+  test-mbsrtowcs-4.sh test-mbsrtowcs-5.sh
 TESTS_ENVIRONMENT += \
   LOCALE_FR='@LOCALE_FR@' \
   LOCALE_FR_UTF8='@LOCALE_FR_UTF8@' \
diff --git a/tests/test-mbsrtowcs-1.sh b/tests/test-mbsrtowcs-1.sh
new file mode 100755 (executable)
index 0000000..abac8d2
--- /dev/null
@@ -0,0 +1,9 @@
+#!/bin/sh
+
+# Test whether the POSIX locale has encoding errors.
+LC_ALL=C \
+${CHECKER} ./test-mbsrtowcs${EXEEXT} 1 || exit 1
+LC_ALL=POSIX \
+${CHECKER} ./test-mbsrtowcs${EXEEXT} 1 || exit 1
+
+exit 0
diff --git a/tests/test-mbsrtowcs-2.sh b/tests/test-mbsrtowcs-2.sh
new file mode 100755 (executable)
index 0000000..508159e
--- /dev/null
@@ -0,0 +1,15 @@
+#!/bin/sh
+
+# Test in an ISO-8859-1 or ISO-8859-15 locale.
+: "${LOCALE_FR=fr_FR}"
+if test $LOCALE_FR = none; then
+  if test -f /usr/bin/localedef; then
+    echo "Skipping test: no traditional french locale is installed"
+  else
+    echo "Skipping test: no traditional french locale is supported"
+  fi
+  exit 77
+fi
+
+LC_ALL=$LOCALE_FR \
+${CHECKER} ./test-mbsrtowcs${EXEEXT} 2
diff --git a/tests/test-mbsrtowcs-3.sh b/tests/test-mbsrtowcs-3.sh
new file mode 100755 (executable)
index 0000000..9c7caee
--- /dev/null
@@ -0,0 +1,15 @@
+#!/bin/sh
+
+# Test whether a specific UTF-8 locale is installed.
+: "${LOCALE_FR_UTF8=fr_FR.UTF-8}"
+if test $LOCALE_FR_UTF8 = none; then
+  if test -f /usr/bin/localedef; then
+    echo "Skipping test: no french Unicode locale is installed"
+  else
+    echo "Skipping test: no french Unicode locale is supported"
+  fi
+  exit 77
+fi
+
+LC_ALL=$LOCALE_FR_UTF8 \
+${CHECKER} ./test-mbsrtowcs${EXEEXT} 3
diff --git a/tests/test-mbsrtowcs-4.sh b/tests/test-mbsrtowcs-4.sh
new file mode 100755 (executable)
index 0000000..87dc7e7
--- /dev/null
@@ -0,0 +1,15 @@
+#!/bin/sh
+
+# Test whether a specific EUC-JP locale is installed.
+: "${LOCALE_JA=ja_JP}"
+if test $LOCALE_JA = none; then
+  if test -f /usr/bin/localedef; then
+    echo "Skipping test: no traditional japanese locale is installed"
+  else
+    echo "Skipping test: no traditional japanese locale is supported"
+  fi
+  exit 77
+fi
+
+LC_ALL=$LOCALE_JA \
+${CHECKER} ./test-mbsrtowcs${EXEEXT} 4
diff --git a/tests/test-mbsrtowcs-5.sh b/tests/test-mbsrtowcs-5.sh
new file mode 100755 (executable)
index 0000000..8e2de64
--- /dev/null
@@ -0,0 +1,15 @@
+#!/bin/sh
+
+# Test whether a specific GB18030 locale is installed.
+: "${LOCALE_ZH_CN=zh_CN.GB18030}"
+if test $LOCALE_ZH_CN = none; then
+  if test -f /usr/bin/localedef; then
+    echo "Skipping test: no transitional chinese locale is installed"
+  else
+    echo "Skipping test: no transitional chinese locale is supported"
+  fi
+  exit 77
+fi
+
+LC_ALL=$LOCALE_ZH_CN \
+${CHECKER} ./test-mbsrtowcs${EXEEXT} 5
index 3c351f2346f93b3b88c4bbc61c2a8e206d88f20d..822d329a4ba5c78c37d70a5458c8461ce5a0585c 100644 (file)
@@ -77,8 +77,8 @@ main (int argc, char *argv[])
      "C" locale.  Furthermore, when you attempt to set the "C" or "POSIX"
      locale via setlocale(), what you get is a "C" locale with UTF-8 encoding,
      that is, effectively the "C.UTF-8" locale.  */
-  if (argc > 1 && strcmp (argv[1], "5") == 0 && MB_CUR_MAX > 1)
-    argv[1] = "2";
+  if (argc > 1 && strcmp (argv[1], "1") == 0 && MB_CUR_MAX > 1)
+    argv[1] = "3";
 #endif
 
   if (argc > 1)
@@ -101,6 +101,72 @@ main (int argc, char *argv[])
           switch (argv[1][0])
             {
             case '1':
+              /* C or POSIX locale.  */
+              {
+                char input[] = "n/a";
+                memset (&state, '\0', sizeof (mbstate_t));
+
+                src = input;
+                temp_state = state;
+                ret = mbsrtowcs (NULL, &src, unlimited ? BUFSIZE : 1, &temp_state);
+                ASSERT (ret == 3);
+                ASSERT (src == input);
+                ASSERT (mbsinit (&state));
+
+                src = input;
+                ret = mbsrtowcs (buf, &src, unlimited ? BUFSIZE : 1, &state);
+                ASSERT (ret == (unlimited ? 3 : 1));
+                ASSERT (src == (unlimited ? NULL : input + 1));
+                ASSERT (buf[0] == 'n');
+                if (unlimited)
+                  {
+                    ASSERT (buf[1] == '/');
+                    ASSERT (buf[2] == 'a');
+                    ASSERT (buf[3] == 0);
+                    ASSERT (buf[4] == (wchar_t) 0xBADFACE);
+                  }
+                else
+                  ASSERT (buf[1] == (wchar_t) 0xBADFACE);
+                ASSERT (mbsinit (&state));
+              }
+              {
+                int c;
+                char input[2];
+
+                memset (&state, '\0', sizeof (mbstate_t));
+                for (c = 0; c < 0x100; c++)
+                  if (c != 0)
+                    {
+                      /* We are testing all nonnull bytes.  */
+                      input[0] = c;
+                      input[1] = '\0';
+
+                      src = input;
+                      ret = mbsrtowcs (NULL, &src, unlimited ? BUFSIZE : 1, &state);
+                      ASSERT (ret == 1);
+                      ASSERT (src == input);
+                      ASSERT (mbsinit (&state));
+
+                      buf[0] = buf[1] = (wchar_t) 0xBADFACE;
+                      src = input;
+                      ret = mbsrtowcs (buf, &src, unlimited ? BUFSIZE : 1, &state);
+                      /* POSIX:2018 says: "In the POSIX locale an [EILSEQ] error
+                         cannot occur since all byte values are valid characters."  */
+                      ASSERT (ret == 1);
+                      ASSERT (src == (unlimited ? NULL : input + 1));
+                      if (c < 0x80)
+                        /* c is an ASCII character.  */
+                        ASSERT (buf[0] == c);
+                      else
+                        /* On most platforms, the bytes 0x80..0xFF map to U+0080..U+00FF.
+                           But on musl libc, the bytes 0x80..0xFF map to U+DF80..U+DFFF.  */
+                        ASSERT (buf[0] == (btowc (c) == 0xDF00 + c ? btowc (c) : c));
+                      ASSERT (mbsinit (&state));
+                    }
+              }
+              break;
+
+            case '2':
               /* Locale encoding is ISO-8859-1 or ISO-8859-15.  */
               {
                 char input[] = "B\374\337er"; /* "Büßer" */
@@ -145,7 +211,7 @@ main (int argc, char *argv[])
               }
               break;
 
-            case '2':
+            case '3':
               /* Locale encoding is UTF-8.  */
               {
                 char input[] = "B\303\274\303\237er"; /* "Büßer" */
@@ -191,7 +257,7 @@ main (int argc, char *argv[])
               }
               break;
 
-            case '3':
+            case '4':
               /* Locale encoding is EUC-JP.  */
               {
                 char input[] = "<\306\374\313\334\270\354>"; /* "<日本語>" */
@@ -244,7 +310,7 @@ main (int argc, char *argv[])
               }
               break;
 
-            case '4':
+            case '5':
               /* Locale encoding is GB18030.  */
               {
                 char input[] = "B\250\271\201\060\211\070er"; /* "Büßer" */
@@ -290,72 +356,6 @@ main (int argc, char *argv[])
               }
               break;
 
-            case '5':
-              /* C or POSIX locale.  */
-              {
-                char input[] = "n/a";
-                memset (&state, '\0', sizeof (mbstate_t));
-
-                src = input;
-                temp_state = state;
-                ret = mbsrtowcs (NULL, &src, unlimited ? BUFSIZE : 1, &temp_state);
-                ASSERT (ret == 3);
-                ASSERT (src == input);
-                ASSERT (mbsinit (&state));
-
-                src = input;
-                ret = mbsrtowcs (buf, &src, unlimited ? BUFSIZE : 1, &state);
-                ASSERT (ret == (unlimited ? 3 : 1));
-                ASSERT (src == (unlimited ? NULL : input + 1));
-                ASSERT (buf[0] == 'n');
-                if (unlimited)
-                  {
-                    ASSERT (buf[1] == '/');
-                    ASSERT (buf[2] == 'a');
-                    ASSERT (buf[3] == 0);
-                    ASSERT (buf[4] == (wchar_t) 0xBADFACE);
-                  }
-                else
-                  ASSERT (buf[1] == (wchar_t) 0xBADFACE);
-                ASSERT (mbsinit (&state));
-              }
-              {
-                int c;
-                char input[2];
-
-                memset (&state, '\0', sizeof (mbstate_t));
-                for (c = 0; c < 0x100; c++)
-                  if (c != 0)
-                    {
-                      /* We are testing all nonnull bytes.  */
-                      input[0] = c;
-                      input[1] = '\0';
-
-                      src = input;
-                      ret = mbsrtowcs (NULL, &src, unlimited ? BUFSIZE : 1, &state);
-                      ASSERT (ret == 1);
-                      ASSERT (src == input);
-                      ASSERT (mbsinit (&state));
-
-                      buf[0] = buf[1] = (wchar_t) 0xBADFACE;
-                      src = input;
-                      ret = mbsrtowcs (buf, &src, unlimited ? BUFSIZE : 1, &state);
-                      /* POSIX:2018 says: "In the POSIX locale an [EILSEQ] error
-                         cannot occur since all byte values are valid characters."  */
-                      ASSERT (ret == 1);
-                      ASSERT (src == (unlimited ? NULL : input + 1));
-                      if (c < 0x80)
-                        /* c is an ASCII character.  */
-                        ASSERT (buf[0] == c);
-                      else
-                        /* On most platforms, the bytes 0x80..0xFF map to U+0080..U+00FF.
-                           But on musl libc, the bytes 0x80..0xFF map to U+DF80..U+DFFF.  */
-                        ASSERT (buf[0] == (btowc (c) == 0xDF00 + c ? btowc (c) : c));
-                      ASSERT (mbsinit (&state));
-                    }
-              }
-              break;
-
             default:
               return 1;
             }
diff --git a/tests/test-mbsrtowcs1.sh b/tests/test-mbsrtowcs1.sh
deleted file mode 100755 (executable)
index f8c54ab..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-#!/bin/sh
-
-# Test in an ISO-8859-1 or ISO-8859-15 locale.
-: "${LOCALE_FR=fr_FR}"
-if test $LOCALE_FR = none; then
-  if test -f /usr/bin/localedef; then
-    echo "Skipping test: no traditional french locale is installed"
-  else
-    echo "Skipping test: no traditional french locale is supported"
-  fi
-  exit 77
-fi
-
-LC_ALL=$LOCALE_FR \
-${CHECKER} ./test-mbsrtowcs${EXEEXT} 1
diff --git a/tests/test-mbsrtowcs2.sh b/tests/test-mbsrtowcs2.sh
deleted file mode 100755 (executable)
index 1cae31c..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-#!/bin/sh
-
-# Test whether a specific UTF-8 locale is installed.
-: "${LOCALE_FR_UTF8=fr_FR.UTF-8}"
-if test $LOCALE_FR_UTF8 = none; then
-  if test -f /usr/bin/localedef; then
-    echo "Skipping test: no french Unicode locale is installed"
-  else
-    echo "Skipping test: no french Unicode locale is supported"
-  fi
-  exit 77
-fi
-
-LC_ALL=$LOCALE_FR_UTF8 \
-${CHECKER} ./test-mbsrtowcs${EXEEXT} 2
diff --git a/tests/test-mbsrtowcs3.sh b/tests/test-mbsrtowcs3.sh
deleted file mode 100755 (executable)
index 908c140..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-#!/bin/sh
-
-# Test whether a specific EUC-JP locale is installed.
-: "${LOCALE_JA=ja_JP}"
-if test $LOCALE_JA = none; then
-  if test -f /usr/bin/localedef; then
-    echo "Skipping test: no traditional japanese locale is installed"
-  else
-    echo "Skipping test: no traditional japanese locale is supported"
-  fi
-  exit 77
-fi
-
-LC_ALL=$LOCALE_JA \
-${CHECKER} ./test-mbsrtowcs${EXEEXT} 3
diff --git a/tests/test-mbsrtowcs4.sh b/tests/test-mbsrtowcs4.sh
deleted file mode 100755 (executable)
index 135bc5f..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-#!/bin/sh
-
-# Test whether a specific GB18030 locale is installed.
-: "${LOCALE_ZH_CN=zh_CN.GB18030}"
-if test $LOCALE_ZH_CN = none; then
-  if test -f /usr/bin/localedef; then
-    echo "Skipping test: no transitional chinese locale is installed"
-  else
-    echo "Skipping test: no transitional chinese locale is supported"
-  fi
-  exit 77
-fi
-
-LC_ALL=$LOCALE_ZH_CN \
-${CHECKER} ./test-mbsrtowcs${EXEEXT} 4
diff --git a/tests/test-mbsrtowcs5.sh b/tests/test-mbsrtowcs5.sh
deleted file mode 100755 (executable)
index 96734a7..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-#!/bin/sh
-
-# Test whether the POSIX locale has encoding errors.
-LC_ALL=C \
-${CHECKER} ./test-mbsrtowcs${EXEEXT} 5 || exit 1
-LC_ALL=POSIX \
-${CHECKER} ./test-mbsrtowcs${EXEEXT} 5 || exit 1
-
-exit 0