unistr/u*-chr: prepare for multibyte tests
[gnulib.git] / tests / unistr / test-chr.h
index 5a021c2..fbed0e1 100644 (file)
@@ -20,16 +20,21 @@ int
 main (void)
 {
   size_t n = 0x100000;
-  UNIT *input = (UNIT *) malloc (n * sizeof (UNIT));
+  size_t length;
+  UNIT *input;
+  uint32_t *input32 = (uint32_t *) malloc (n * sizeof (uint32_t));
+  ASSERT (input32);
+
+  input32[0] = 'a';
+  input32[1] = 'b';
+  u32_set (input32 + 2, 'c', 1024);
+  u32_set (input32 + 1026, 'd', n - 1028);
+  input32[n - 2] = 'e';
+  input32[n - 1] = 'a';
+
+  input = U32_TO_U (input32, n, NULL, &length);
   ASSERT (input);
 
-  input[0] = 'a';
-  input[1] = 'b';
-  U_SET (input + 2, 'c', 1024);
-  U_SET (input + 1026, 'd', n - 1028);
-  input[n - 2] = 'e';
-  input[n - 1] = 'a';
-
   /* Basic behavior tests.  */
   ASSERT (U_CHR (input, n, 'a') == input);