summaryrefslogtreecommitdiff
path: root/tests/uninorm
diff options
context:
space:
mode:
Diffstat (limited to 'tests/uninorm')
-rw-r--r--tests/uninorm/test-canonical-decomposition.c17
-rw-r--r--tests/uninorm/test-compat-decomposition.c18
-rw-r--r--tests/uninorm/test-composition.c17
-rw-r--r--tests/uninorm/test-decomposing-form.c17
-rw-r--r--tests/uninorm/test-decomposition.c17
-rw-r--r--tests/uninorm/test-nfc.c2
-rw-r--r--tests/uninorm/test-nfd.c2
-rw-r--r--tests/uninorm/test-nfkc.c2
-rw-r--r--tests/uninorm/test-nfkd.c2
-rw-r--r--tests/uninorm/test-u16-nfc.c167
-rw-r--r--tests/uninorm/test-u16-nfd.c161
-rw-r--r--tests/uninorm/test-u16-nfkc.c179
-rw-r--r--tests/uninorm/test-u16-nfkd.c163
-rw-r--r--tests/uninorm/test-u16-normcmp.c18
-rw-r--r--tests/uninorm/test-u16-normcmp.h4
-rw-r--r--tests/uninorm/test-u16-normcoll.c18
-rw-r--r--tests/uninorm/test-u32-nfc-big.c24
-rw-r--r--tests/uninorm/test-u32-nfc.c167
-rw-r--r--tests/uninorm/test-u32-nfd-big.c24
-rw-r--r--tests/uninorm/test-u32-nfd.c161
-rw-r--r--tests/uninorm/test-u32-nfkc-big.c24
-rw-r--r--tests/uninorm/test-u32-nfkc.c179
-rw-r--r--tests/uninorm/test-u32-nfkd-big.c24
-rw-r--r--tests/uninorm/test-u32-nfkd.c163
-rw-r--r--tests/uninorm/test-u32-normalize-big.c273
-rw-r--r--tests/uninorm/test-u32-normalize-big.h14
-rw-r--r--tests/uninorm/test-u32-normcmp.c18
-rw-r--r--tests/uninorm/test-u32-normcmp.h4
-rw-r--r--tests/uninorm/test-u32-normcoll.c18
-rw-r--r--tests/uninorm/test-u8-nfc.c225
-rw-r--r--tests/uninorm/test-u8-nfd.c217
-rw-r--r--tests/uninorm/test-u8-nfkc.c245
-rw-r--r--tests/uninorm/test-u8-nfkd.c221
-rw-r--r--tests/uninorm/test-u8-normcmp.c18
-rw-r--r--tests/uninorm/test-u8-normcmp.h4
-rw-r--r--tests/uninorm/test-u8-normcoll.c18
-rw-r--r--tests/uninorm/test-uninorm-filter-nfc.c39
37 files changed, 1277 insertions, 1607 deletions
diff --git a/tests/uninorm/test-canonical-decomposition.c b/tests/uninorm/test-canonical-decomposition.c
index 040011b5..f97bc443 100644
--- a/tests/uninorm/test-canonical-decomposition.c
+++ b/tests/uninorm/test-canonical-decomposition.c
@@ -1,5 +1,5 @@
/* Test of canonical decomposition of Unicode characters.
- Copyright (C) 2009 Free Software Foundation, Inc.
+ Copyright (C) 2009, 2010 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -20,20 +20,7 @@
#include "uninorm.h"
-#include <stdio.h>
-#include <stdlib.h>
-
-#define ASSERT(expr) \
- do \
- { \
- if (!(expr)) \
- { \
- fprintf (stderr, "%s:%d: assertion failed\n", __FILE__, __LINE__); \
- fflush (stderr); \
- abort (); \
- } \
- } \
- while (0)
+#include "macros.h"
int
main ()
diff --git a/tests/uninorm/test-compat-decomposition.c b/tests/uninorm/test-compat-decomposition.c
index 49a2b09f..eeda95bc 100644
--- a/tests/uninorm/test-compat-decomposition.c
+++ b/tests/uninorm/test-compat-decomposition.c
@@ -1,5 +1,5 @@
/* Test of compatibility decomposition of Unicode characters.
- Copyright (C) 2009 Free Software Foundation, Inc.
+ Copyright (C) 2009, 2010 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -20,22 +20,8 @@
#include "uninorm/decompose-internal.h"
-#include <stdio.h>
-#include <stdlib.h>
-
#include "uninorm.h"
-
-#define ASSERT(expr) \
- do \
- { \
- if (!(expr)) \
- { \
- fprintf (stderr, "%s:%d: assertion failed\n", __FILE__, __LINE__); \
- fflush (stderr); \
- abort (); \
- } \
- } \
- while (0)
+#include "macros.h"
int
main ()
diff --git a/tests/uninorm/test-composition.c b/tests/uninorm/test-composition.c
index dbadbbac..bd089e6d 100644
--- a/tests/uninorm/test-composition.c
+++ b/tests/uninorm/test-composition.c
@@ -1,5 +1,5 @@
/* Test of canonical composition of Unicode characters.
- Copyright (C) 2009 Free Software Foundation, Inc.
+ Copyright (C) 2009, 2010 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -20,20 +20,7 @@
#include "uninorm.h"
-#include <stdio.h>
-#include <stdlib.h>
-
-#define ASSERT(expr) \
- do \
- { \
- if (!(expr)) \
- { \
- fprintf (stderr, "%s:%d: assertion failed\n", __FILE__, __LINE__); \
- fflush (stderr); \
- abort (); \
- } \
- } \
- while (0)
+#include "macros.h"
int
main ()
diff --git a/tests/uninorm/test-decomposing-form.c b/tests/uninorm/test-decomposing-form.c
index 3802c3fe..6a1b7c41 100644
--- a/tests/uninorm/test-decomposing-form.c
+++ b/tests/uninorm/test-decomposing-form.c
@@ -1,5 +1,5 @@
/* Test of decomposing variant of a normalization form.
- Copyright (C) 2009 Free Software Foundation, Inc.
+ Copyright (C) 2009, 2010 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -20,20 +20,7 @@
#include "uninorm.h"
-#include <stdio.h>
-#include <stdlib.h>
-
-#define ASSERT(expr) \
- do \
- { \
- if (!(expr)) \
- { \
- fprintf (stderr, "%s:%d: assertion failed\n", __FILE__, __LINE__); \
- fflush (stderr); \
- abort (); \
- } \
- } \
- while (0)
+#include "macros.h"
int
main ()
diff --git a/tests/uninorm/test-decomposition.c b/tests/uninorm/test-decomposition.c
index 684dee45..3cef3939 100644
--- a/tests/uninorm/test-decomposition.c
+++ b/tests/uninorm/test-decomposition.c
@@ -1,5 +1,5 @@
/* Test of decomposition of Unicode characters.
- Copyright (C) 2009 Free Software Foundation, Inc.
+ Copyright (C) 2009, 2010 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -20,20 +20,7 @@
#include "uninorm.h"
-#include <stdio.h>
-#include <stdlib.h>
-
-#define ASSERT(expr) \
- do \
- { \
- if (!(expr)) \
- { \
- fprintf (stderr, "%s:%d: assertion failed\n", __FILE__, __LINE__); \
- fflush (stderr); \
- abort (); \
- } \
- } \
- while (0)
+#include "macros.h"
int
main ()
diff --git a/tests/uninorm/test-nfc.c b/tests/uninorm/test-nfc.c
index ca957102..6fd86d84 100644
--- a/tests/uninorm/test-nfc.c
+++ b/tests/uninorm/test-nfc.c
@@ -1,5 +1,5 @@
/* Test of canonical normalization of Unicode strings.
- Copyright (C) 2009 Free Software Foundation, Inc.
+ Copyright (C) 2009, 2010 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/tests/uninorm/test-nfd.c b/tests/uninorm/test-nfd.c
index 2a7e55b0..d89ba77d 100644
--- a/tests/uninorm/test-nfd.c
+++ b/tests/uninorm/test-nfd.c
@@ -1,5 +1,5 @@
/* Test of canonical decomposition of Unicode strings.
- Copyright (C) 2009 Free Software Foundation, Inc.
+ Copyright (C) 2009, 2010 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/tests/uninorm/test-nfkc.c b/tests/uninorm/test-nfkc.c
index 2e57a15e..68474a8b 100644
--- a/tests/uninorm/test-nfkc.c
+++ b/tests/uninorm/test-nfkc.c
@@ -1,5 +1,5 @@
/* Test of compatibility normalization of Unicode strings.
- Copyright (C) 2009 Free Software Foundation, Inc.
+ Copyright (C) 2009, 2010 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/tests/uninorm/test-nfkd.c b/tests/uninorm/test-nfkd.c
index 8e330feb..cb8a2dfd 100644
--- a/tests/uninorm/test-nfkd.c
+++ b/tests/uninorm/test-nfkd.c
@@ -1,5 +1,5 @@
/* Test of compatibility decomposition of Unicode strings.
- Copyright (C) 2009 Free Software Foundation, Inc.
+ Copyright (C) 2009, 2010 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/tests/uninorm/test-u16-nfc.c b/tests/uninorm/test-u16-nfc.c
index 1bf9a94d..b5955003 100644
--- a/tests/uninorm/test-u16-nfc.c
+++ b/tests/uninorm/test-u16-nfc.c
@@ -1,5 +1,5 @@
/* Test of canonical normalization of UTF-16 strings.
- Copyright (C) 2009 Free Software Foundation, Inc.
+ Copyright (C) 2009, 2010 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -18,29 +18,16 @@
#include <config.h>
-#if GNULIB_UNINORM_U16_NORMALIZE
+#if GNULIB_TEST_UNINORM_U16_NORMALIZE
#include "uninorm.h"
#include <signal.h>
-#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include "unistr.h"
-
-#define SIZEOF(array) (sizeof (array) / sizeof (array[0]))
-#define ASSERT(expr) \
- do \
- { \
- if (!(expr)) \
- { \
- fprintf (stderr, "%s:%d: assertion failed\n", __FILE__, __LINE__); \
- fflush (stderr); \
- abort (); \
- } \
- } \
- while (0)
+#include "macros.h"
static int
check (const uint16_t *input, size_t input_length,
@@ -68,13 +55,13 @@ check (const uint16_t *input, size_t input_length,
preallocated = (uint16_t *) malloc (length * sizeof (uint16_t));
result = u16_normalize (UNINORM_NFC, input, input_length, preallocated, &length);
if (!(result != NULL))
- return 4;
+ return 4;
if (!(result != preallocated))
- return 5;
+ return 5;
if (!(length == expected_length))
- return 6;
+ return 6;
if (!(u16_cmp (result, expected, expected_length) == 0))
- return 7;
+ return 7;
free (result);
free (preallocated);
}
@@ -241,20 +228,20 @@ test_u16_nfc (void)
{ /* "Grüß Gott. Здравствуйте! x=(-b±sqrt(b²-4ac))/(2a) 日本語,中文,한글" */
static const uint16_t input[] =
{ 'G', 'r', 0x00FC, 0x00DF, ' ', 'G', 'o', 't', 't', '.', ' ',
- 0x0417, 0x0434, 0x0440, 0x0430, 0x0432, 0x0441, 0x0442, 0x0432, 0x0443,
- 0x0439, 0x0442, 0x0435, '!', ' ',
- 'x', '=', '(', '-', 'b', 0x00B1, 's', 'q', 'r', 't', '(', 'b', 0x00B2,
- '-', '4', 'a', 'c', ')', ')', '/', '(', '2', 'a', ')', ' ', ' ',
- 0x65E5, 0x672C, 0x8A9E, ',', 0x4E2D, 0x6587, ',', 0xD55C, 0xAE00, '\n'
+ 0x0417, 0x0434, 0x0440, 0x0430, 0x0432, 0x0441, 0x0442, 0x0432, 0x0443,
+ 0x0439, 0x0442, 0x0435, '!', ' ',
+ 'x', '=', '(', '-', 'b', 0x00B1, 's', 'q', 'r', 't', '(', 'b', 0x00B2,
+ '-', '4', 'a', 'c', ')', ')', '/', '(', '2', 'a', ')', ' ', ' ',
+ 0x65E5, 0x672C, 0x8A9E, ',', 0x4E2D, 0x6587, ',', 0xD55C, 0xAE00, '\n'
};
static const uint16_t decomposed[] =
{ 'G', 'r', 0x0075, 0x0308, 0x00DF, ' ', 'G', 'o', 't', 't', '.', ' ',
- 0x0417, 0x0434, 0x0440, 0x0430, 0x0432, 0x0441, 0x0442, 0x0432, 0x0443,
- 0x0438, 0x0306, 0x0442, 0x0435, '!', ' ',
- 'x', '=', '(', '-', 'b', 0x00B1, 's', 'q', 'r', 't', '(', 'b', 0x00B2,
- '-', '4', 'a', 'c', ')', ')', '/', '(', '2', 'a', ')', ' ', ' ',
- 0x65E5, 0x672C, 0x8A9E, ',', 0x4E2D, 0x6587, ',',
- 0x1112, 0x1161, 0x11AB, 0x1100, 0x1173, 0x11AF, '\n'
+ 0x0417, 0x0434, 0x0440, 0x0430, 0x0432, 0x0441, 0x0442, 0x0432, 0x0443,
+ 0x0438, 0x0306, 0x0442, 0x0435, '!', ' ',
+ 'x', '=', '(', '-', 'b', 0x00B1, 's', 'q', 'r', 't', '(', 'b', 0x00B2,
+ '-', '4', 'a', 'c', ')', ')', '/', '(', '2', 'a', ')', ' ', ' ',
+ 0x65E5, 0x672C, 0x8A9E, ',', 0x4E2D, 0x6587, ',',
+ 0x1112, 0x1161, 0x11AB, 0x1100, 0x1173, 0x11AF, '\n'
};
ASSERT (check (input, SIZEOF (input), input, SIZEOF (input)) == 0);
ASSERT (check (decomposed, SIZEOF (decomposed), input, SIZEOF (input)) == 0);
@@ -272,65 +259,65 @@ test_u16_nfc (void)
int pass;
for (pass = 0; pass < 3; pass++)
{
- size_t repeat = 1;
- size_t m = 100000;
- uint16_t *input = (uint16_t *) malloc (2 * m * sizeof (uint16_t));
- if (input != NULL)
- {
- uint16_t *expected = input + m;
- size_t m1 = m / 2;
- size_t m2 = (m - 1) / 2;
- /* NB: m1 + m2 == m - 1. */
- uint16_t *p;
- size_t i;
-
- input[0] = 0x0041;
- p = input + 1;
- switch (pass)
- {
- case 0:
- for (i = 0; i < m1; i++)
- *p++ = 0x0319;
- for (i = 0; i < m2; i++)
- *p++ = 0x0300;
- break;
-
- case 1:
- for (i = 0; i < m2; i++)
- *p++ = 0x0300;
- for (i = 0; i < m1; i++)
- *p++ = 0x0319;
- break;
-
- case 2:
- for (i = 0; i < m2; i++)
- {
- *p++ = 0x0319;
- *p++ = 0x0300;
- }
- for (; i < m1; i++)
- *p++ = 0x0319;
- break;
-
- default:
- abort ();
- }
-
- expected[0] = 0x00C0;
- p = expected + 1;
- for (i = 0; i < m1; i++)
- *p++ = 0x0319;
- for (i = 0; i < m2 - 1; i++)
- *p++ = 0x0300;
-
- for (; repeat > 0; repeat--)
- {
- ASSERT (check (input, m, expected, m - 1) == 0);
- ASSERT (check (expected, m - 1, expected, m - 1) == 0);
- }
-
- free (input);
- }
+ size_t repeat = 1;
+ size_t m = 100000;
+ uint16_t *input = (uint16_t *) malloc (2 * m * sizeof (uint16_t));
+ if (input != NULL)
+ {
+ uint16_t *expected = input + m;
+ size_t m1 = m / 2;
+ size_t m2 = (m - 1) / 2;
+ /* NB: m1 + m2 == m - 1. */
+ uint16_t *p;
+ size_t i;
+
+ input[0] = 0x0041;
+ p = input + 1;
+ switch (pass)
+ {
+ case 0:
+ for (i = 0; i < m1; i++)
+ *p++ = 0x0319;
+ for (i = 0; i < m2; i++)
+ *p++ = 0x0300;
+ break;
+
+ case 1:
+ for (i = 0; i < m2; i++)
+ *p++ = 0x0300;
+ for (i = 0; i < m1; i++)
+ *p++ = 0x0319;
+ break;
+
+ case 2:
+ for (i = 0; i < m2; i++)
+ {
+ *p++ = 0x0319;
+ *p++ = 0x0300;
+ }
+ for (; i < m1; i++)
+ *p++ = 0x0319;
+ break;
+
+ default:
+ abort ();
+ }
+
+ expected[0] = 0x00C0;
+ p = expected + 1;
+ for (i = 0; i < m1; i++)
+ *p++ = 0x0319;
+ for (i = 0; i < m2 - 1; i++)
+ *p++ = 0x0300;
+
+ for (; repeat > 0; repeat--)
+ {
+ ASSERT (check (input, m, expected, m - 1) == 0);
+ ASSERT (check (expected, m - 1, expected, m - 1) == 0);
+ }
+
+ free (input);
+ }
}
}
}
diff --git a/tests/uninorm/test-u16-nfd.c b/tests/uninorm/test-u16-nfd.c
index 34789b8d..0e084c91 100644
--- a/tests/uninorm/test-u16-nfd.c
+++ b/tests/uninorm/test-u16-nfd.c
@@ -1,5 +1,5 @@
/* Test of canonical decomposition of UTF-16 strings.
- Copyright (C) 2009 Free Software Foundation, Inc.
+ Copyright (C) 2009, 2010 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -18,29 +18,16 @@
#include <config.h>
-#if GNULIB_UNINORM_U16_NORMALIZE
+#if GNULIB_TEST_UNINORM_U16_NORMALIZE
#include "uninorm.h"
#include <signal.h>
-#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include "unistr.h"
-
-#define SIZEOF(array) (sizeof (array) / sizeof (array[0]))
-#define ASSERT(expr) \
- do \
- { \
- if (!(expr)) \
- { \
- fprintf (stderr, "%s:%d: assertion failed\n", __FILE__, __LINE__); \
- fflush (stderr); \
- abort (); \
- } \
- } \
- while (0)
+#include "macros.h"
static int
check (const uint16_t *input, size_t input_length,
@@ -68,13 +55,13 @@ check (const uint16_t *input, size_t input_length,
preallocated = (uint16_t *) malloc (length * sizeof (uint16_t));
result = u16_normalize (UNINORM_NFD, input, input_length, preallocated, &length);
if (!(result != NULL))
- return 4;
+ return 4;
if (!(result != preallocated))
- return 5;
+ return 5;
if (!(length == expected_length))
- return 6;
+ return 6;
if (!(u16_cmp (result, expected, expected_length) == 0))
- return 7;
+ return 7;
free (result);
free (preallocated);
}
@@ -229,20 +216,20 @@ test_u16_nfd (void)
{ /* "Grüß Gott. Здравствуйте! x=(-b±sqrt(b²-4ac))/(2a) 日本語,中文,한글" */
static const uint16_t input[] =
{ 'G', 'r', 0x00FC, 0x00DF, ' ', 'G', 'o', 't', 't', '.', ' ',
- 0x0417, 0x0434, 0x0440, 0x0430, 0x0432, 0x0441, 0x0442, 0x0432, 0x0443,
- 0x0439, 0x0442, 0x0435, '!', ' ',
- 'x', '=', '(', '-', 'b', 0x00B1, 's', 'q', 'r', 't', '(', 'b', 0x00B2,
- '-', '4', 'a', 'c', ')', ')', '/', '(', '2', 'a', ')', ' ', ' ',
- 0x65E5, 0x672C, 0x8A9E, ',', 0x4E2D, 0x6587, ',', 0xD55C, 0xAE00, '\n'
+ 0x0417, 0x0434, 0x0440, 0x0430, 0x0432, 0x0441, 0x0442, 0x0432, 0x0443,
+ 0x0439, 0x0442, 0x0435, '!', ' ',
+ 'x', '=', '(', '-', 'b', 0x00B1, 's', 'q', 'r', 't', '(', 'b', 0x00B2,
+ '-', '4', 'a', 'c', ')', ')', '/', '(', '2', 'a', ')', ' ', ' ',
+ 0x65E5, 0x672C, 0x8A9E, ',', 0x4E2D, 0x6587, ',', 0xD55C, 0xAE00, '\n'
};
static const uint16_t expected[] =
{ 'G', 'r', 0x0075, 0x0308, 0x00DF, ' ', 'G', 'o', 't', 't', '.', ' ',
- 0x0417, 0x0434, 0x0440, 0x0430, 0x0432, 0x0441, 0x0442, 0x0432, 0x0443,
- 0x0438, 0x0306, 0x0442, 0x0435, '!', ' ',
- 'x', '=', '(', '-', 'b', 0x00B1, 's', 'q', 'r', 't', '(', 'b', 0x00B2,
- '-', '4', 'a', 'c', ')', ')', '/', '(', '2', 'a', ')', ' ', ' ',
- 0x65E5, 0x672C, 0x8A9E, ',', 0x4E2D, 0x6587, ',',
- 0x1112, 0x1161, 0x11AB, 0x1100, 0x1173, 0x11AF, '\n'
+ 0x0417, 0x0434, 0x0440, 0x0430, 0x0432, 0x0441, 0x0442, 0x0432, 0x0443,
+ 0x0438, 0x0306, 0x0442, 0x0435, '!', ' ',
+ 'x', '=', '(', '-', 'b', 0x00B1, 's', 'q', 'r', 't', '(', 'b', 0x00B2,
+ '-', '4', 'a', 'c', ')', ')', '/', '(', '2', 'a', ')', ' ', ' ',
+ 0x65E5, 0x672C, 0x8A9E, ',', 0x4E2D, 0x6587, ',',
+ 0x1112, 0x1161, 0x11AB, 0x1100, 0x1173, 0x11AF, '\n'
};
ASSERT (check (input, SIZEOF (input), expected, SIZEOF (expected)) == 0);
}
@@ -259,62 +246,62 @@ test_u16_nfd (void)
int pass;
for (pass = 0; pass < 3; pass++)
{
- size_t repeat = 1;
- size_t m = 100000;
- uint16_t *input = (uint16_t *) malloc (2 * m * sizeof (uint16_t));
- if (input != NULL)
- {
- uint16_t *expected = input + m;
- size_t m1 = m / 2;
- size_t m2 = (m - 1) / 2;
- /* NB: m1 + m2 == m - 1. */
- uint16_t *p;
- size_t i;
-
- input[0] = 0x0041;
- p = input + 1;
- switch (pass)
- {
- case 0:
- for (i = 0; i < m1; i++)
- *p++ = 0x0319;
- for (i = 0; i < m2; i++)
- *p++ = 0x0300;
- break;
-
- case 1:
- for (i = 0; i < m2; i++)
- *p++ = 0x0300;
- for (i = 0; i < m1; i++)
- *p++ = 0x0319;
- break;
-
- case 2:
- for (i = 0; i < m2; i++)
- {
- *p++ = 0x0319;
- *p++ = 0x0300;
- }
- for (; i < m1; i++)
- *p++ = 0x0319;
- break;
-
- default:
- abort ();
- }
-
- expected[0] = 0x0041;
- p = expected + 1;
- for (i = 0; i < m1; i++)
- *p++ = 0x0319;
- for (i = 0; i < m2; i++)
- *p++ = 0x0300;
-
- for (; repeat > 0; repeat--)
- ASSERT (check (input, m, expected, m) == 0);
-
- free (input);
- }
+ size_t repeat = 1;
+ size_t m = 100000;
+ uint16_t *input = (uint16_t *) malloc (2 * m * sizeof (uint16_t));
+ if (input != NULL)
+ {
+ uint16_t *expected = input + m;
+ size_t m1 = m / 2;
+ size_t m2 = (m - 1) / 2;
+ /* NB: m1 + m2 == m - 1. */
+ uint16_t *p;
+ size_t i;
+
+ input[0] = 0x0041;
+ p = input + 1;
+ switch (pass)
+ {
+ case 0:
+ for (i = 0; i < m1; i++)
+ *p++ = 0x0319;
+ for (i = 0; i < m2; i++)
+ *p++ = 0x0300;
+ break;
+
+ case 1:
+ for (i = 0; i < m2; i++)
+ *p++ = 0x0300;
+ for (i = 0; i < m1; i++)
+ *p++ = 0x0319;
+ break;
+
+ case 2:
+ for (i = 0; i < m2; i++)
+ {
+ *p++ = 0x0319;
+ *p++ = 0x0300;
+ }
+ for (; i < m1; i++)
+ *p++ = 0x0319;
+ break;
+
+ default:
+ abort ();
+ }
+
+ expected[0] = 0x0041;
+ p = expected + 1;
+ for (i = 0; i < m1; i++)
+ *p++ = 0x0319;
+ for (i = 0; i < m2; i++)
+ *p++ = 0x0300;
+
+ for (; repeat > 0; repeat--)
+ ASSERT (check (input, m, expected, m) == 0);
+
+ free (input);
+ }
}
}
}
diff --git a/tests/uninorm/test-u16-nfkc.c b/tests/uninorm/test-u16-nfkc.c
index 4ac8f7ed..7fcec7c5 100644
--- a/tests/uninorm/test-u16-nfkc.c
+++ b/tests/uninorm/test-u16-nfkc.c
@@ -1,5 +1,5 @@
/* Test of compatibility normalization of UTF-16 strings.
- Copyright (C) 2009 Free Software Foundation, Inc.
+ Copyright (C) 2009, 2010 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -18,29 +18,16 @@
#include <config.h>
-#if GNULIB_UNINORM_U16_NORMALIZE
+#if GNULIB_TEST_UNINORM_U16_NORMALIZE
#include "uninorm.h"
#include <signal.h>
-#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include "unistr.h"
-
-#define SIZEOF(array) (sizeof (array) / sizeof (array[0]))
-#define ASSERT(expr) \
- do \
- { \
- if (!(expr)) \
- { \
- fprintf (stderr, "%s:%d: assertion failed\n", __FILE__, __LINE__); \
- fflush (stderr); \
- abort (); \
- } \
- } \
- while (0)
+#include "macros.h"
static int
check (const uint16_t *input, size_t input_length,
@@ -68,13 +55,13 @@ check (const uint16_t *input, size_t input_length,
preallocated = (uint16_t *) malloc (length * sizeof (uint16_t));
result = u16_normalize (UNINORM_NFKC, input, input_length, preallocated, &length);
if (!(result != NULL))
- return 4;
+ return 4;
if (!(result != preallocated))
- return 5;
+ return 5;
if (!(length == expected_length))
- return 6;
+ return 6;
if (!(u16_cmp (result, expected, expected_length) == 0))
- return 7;
+ return 7;
free (result);
free (preallocated);
}
@@ -257,7 +244,7 @@ test_u16_nfkc (void)
static const uint16_t input[] = { 0xFDFA };
static const uint16_t decomposed[] =
{ 0x0635, 0x0644, 0x0649, 0x0020, 0x0627, 0x0644, 0x0644, 0x0647, 0x0020,
- 0x0639, 0x0644, 0x064A, 0x0647, 0x0020, 0x0648, 0x0633, 0x0644, 0x0645
+ 0x0639, 0x0644, 0x064A, 0x0647, 0x0020, 0x0648, 0x0633, 0x0644, 0x0645
};
ASSERT (check (input, SIZEOF (input), decomposed, SIZEOF (decomposed)) == 0);
ASSERT (check (decomposed, SIZEOF (decomposed), decomposed, SIZEOF (decomposed)) == 0);
@@ -280,28 +267,28 @@ test_u16_nfkc (void)
{ /* "Grüß Gott. Здравствуйте! x=(-b±sqrt(b²-4ac))/(2a) 日本語,中文,한글" */
static const uint16_t input[] =
{ 'G', 'r', 0x00FC, 0x00DF, ' ', 'G', 'o', 't', 't', '.', ' ',
- 0x0417, 0x0434, 0x0440, 0x0430, 0x0432, 0x0441, 0x0442, 0x0432, 0x0443,
- 0x0439, 0x0442, 0x0435, '!', ' ',
- 'x', '=', '(', '-', 'b', 0x00B1, 's', 'q', 'r', 't', '(', 'b', 0x00B2,
- '-', '4', 'a', 'c', ')', ')', '/', '(', '2', 'a', ')', ' ', ' ',
- 0x65E5, 0x672C, 0x8A9E, ',', 0x4E2D, 0x6587, ',', 0xD55C, 0xAE00, '\n'
+ 0x0417, 0x0434, 0x0440, 0x0430, 0x0432, 0x0441, 0x0442, 0x0432, 0x0443,
+ 0x0439, 0x0442, 0x0435, '!', ' ',
+ 'x', '=', '(', '-', 'b', 0x00B1, 's', 'q', 'r', 't', '(', 'b', 0x00B2,
+ '-', '4', 'a', 'c', ')', ')', '/', '(', '2', 'a', ')', ' ', ' ',
+ 0x65E5, 0x672C, 0x8A9E, ',', 0x4E2D, 0x6587, ',', 0xD55C, 0xAE00, '\n'
};
static const uint16_t decomposed[] =
{ 'G', 'r', 0x0075, 0x0308, 0x00DF, ' ', 'G', 'o', 't', 't', '.', ' ',
- 0x0417, 0x0434, 0x0440, 0x0430, 0x0432, 0x0441, 0x0442, 0x0432, 0x0443,
- 0x0438, 0x0306, 0x0442, 0x0435, '!', ' ',
- 'x', '=', '(', '-', 'b', 0x00B1, 's', 'q', 'r', 't', '(', 'b', 0x0032,
- '-', '4', 'a', 'c', ')', ')', '/', '(', '2', 'a', ')', ' ', ' ',
- 0x65E5, 0x672C, 0x8A9E, ',', 0x4E2D, 0x6587, ',',
- 0x1112, 0x1161, 0x11AB, 0x1100, 0x1173, 0x11AF, '\n'
+ 0x0417, 0x0434, 0x0440, 0x0430, 0x0432, 0x0441, 0x0442, 0x0432, 0x0443,
+ 0x0438, 0x0306, 0x0442, 0x0435, '!', ' ',
+ 'x', '=', '(', '-', 'b', 0x00B1, 's', 'q', 'r', 't', '(', 'b', 0x0032,
+ '-', '4', 'a', 'c', ')', ')', '/', '(', '2', 'a', ')', ' ', ' ',
+ 0x65E5, 0x672C, 0x8A9E, ',', 0x4E2D, 0x6587, ',',
+ 0x1112, 0x1161, 0x11AB, 0x1100, 0x1173, 0x11AF, '\n'
};
static const uint16_t expected[] =
{ 'G', 'r', 0x00FC, 0x00DF, ' ', 'G', 'o', 't', 't', '.', ' ',
- 0x0417, 0x0434, 0x0440, 0x0430, 0x0432, 0x0441, 0x0442, 0x0432, 0x0443,
- 0x0439, 0x0442, 0x0435, '!', ' ',
- 'x', '=', '(', '-', 'b', 0x00B1, 's', 'q', 'r', 't', '(', 'b', 0x0032,
- '-', '4', 'a', 'c', ')', ')', '/', '(', '2', 'a', ')', ' ', ' ',
- 0x65E5, 0x672C, 0x8A9E, ',', 0x4E2D, 0x6587, ',', 0xD55C, 0xAE00, '\n'
+ 0x0417, 0x0434, 0x0440, 0x0430, 0x0432, 0x0441, 0x0442, 0x0432, 0x0443,
+ 0x0439, 0x0442, 0x0435, '!', ' ',
+ 'x', '=', '(', '-', 'b', 0x00B1, 's', 'q', 'r', 't', '(', 'b', 0x0032,
+ '-', '4', 'a', 'c', ')', ')', '/', '(', '2', 'a', ')', ' ', ' ',
+ 0x65E5, 0x672C, 0x8A9E, ',', 0x4E2D, 0x6587, ',', 0xD55C, 0xAE00, '\n'
};
ASSERT (check (input, SIZEOF (input), expected, SIZEOF (expected)) == 0);
ASSERT (check (decomposed, SIZEOF (decomposed), expected, SIZEOF (expected)) == 0);
@@ -320,65 +307,65 @@ test_u16_nfkc (void)
int pass;
for (pass = 0; pass < 3; pass++)
{
- size_t repeat = 1;
- size_t m = 100000;
- uint16_t *input = (uint16_t *) malloc (2 * m * sizeof (uint16_t));
- if (input != NULL)
- {
- uint16_t *expected = input + m;
- size_t m1 = m / 2;
- size_t m2 = (m - 1) / 2;
- /* NB: m1 + m2 == m - 1. */
- uint16_t *p;
- size_t i;
-
- input[0] = 0x0041;
- p = input + 1;
- switch (pass)
- {
- case 0:
- for (i = 0; i < m1; i++)
- *p++ = 0x0319;
- for (i = 0; i < m2; i++)
- *p++ = 0x0300;
- break;
-
- case 1:
- for (i = 0; i < m2; i++)
- *p++ = 0x0300;
- for (i = 0; i < m1; i++)
- *p++ = 0x0319;
- break;
-
- case 2:
- for (i = 0; i < m2; i++)
- {
- *p++ = 0x0319;
- *p++ = 0x0300;
- }
- for (; i < m1; i++)
- *p++ = 0x0319;
- break;
-
- default:
- abort ();
- }
-
- expected[0] = 0x00C0;
- p = expected + 1;
- for (i = 0; i < m1; i++)
- *p++ = 0x0319;
- for (i = 0; i < m2 - 1; i++)
- *p++ = 0x0300;
-
- for (; repeat > 0; repeat--)
- {
- ASSERT (check (input, m, expected, m - 1) == 0);
- ASSERT (check (expected, m - 1, expected, m - 1) == 0);
- }
-
- free (input);
- }
+ size_t repeat = 1;
+ size_t m = 100000;
+ uint16_t *input = (uint16_t *) malloc (2 * m * sizeof (uint16_t));
+ if (input != NULL)
+ {
+ uint16_t *expected = input + m;
+ size_t m1 = m / 2;
+ size_t m2 = (m - 1) / 2;
+ /* NB: m1 + m2 == m - 1. */
+ uint16_t *p;
+ size_t i;
+
+ input[0] = 0x0041;
+ p = input + 1;
+ switch (pass)
+ {
+ case 0:
+ for (i = 0; i < m1; i++)
+ *p++ = 0x0319;
+ for (i = 0; i < m2; i++)
+ *p++ = 0x0300;
+ break;
+
+ case 1:
+ for (i = 0; i < m2; i++)
+ *p++ = 0x0300;
+ for (i = 0; i < m1; i++)
+ *p++ = 0x0319;
+ break;
+
+ case 2:
+ for (i = 0; i < m2; i++)
+ {
+ *p++ = 0x0319;
+ *p++ = 0x0300;
+ }
+ for (; i < m1; i++)
+ *p++ = 0x0319;
+ break;
+
+ default:
+ abort ();
+ }
+
+ expected[0] = 0x00C0;
+ p = expected + 1;
+ for (i = 0; i < m1; i++)
+ *p++ = 0x0319;
+ for (i = 0; i < m2 - 1; i++)
+ *p++ = 0x0300;
+
+ for (; repeat > 0; repeat--)
+ {
+ ASSERT (check (input, m, expected, m - 1) == 0);
+ ASSERT (check (expected, m - 1, expected, m - 1) == 0);
+ }
+
+ free (input);
+ }
}
}
}
diff --git a/tests/uninorm/test-u16-nfkd.c b/tests/uninorm/test-u16-nfkd.c
index 6dfa39f3..4395d01c 100644
--- a/tests/uninorm/test-u16-nfkd.c
+++ b/tests/uninorm/test-u16-nfkd.c
@@ -1,5 +1,5 @@
/* Test of compatibility decomposition of UTF-16 strings.
- Copyright (C) 2009 Free Software Foundation, Inc.
+ Copyright (C) 2009, 2010 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -18,29 +18,16 @@
#include <config.h>
-#if GNULIB_UNINORM_U16_NORMALIZE
+#if GNULIB_TEST_UNINORM_U16_NORMALIZE
#include "uninorm.h"
#include <signal.h>
-#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include "unistr.h"
-
-#define SIZEOF(array) (sizeof (array) / sizeof (array[0]))
-#define ASSERT(expr) \
- do \
- { \
- if (!(expr)) \
- { \
- fprintf (stderr, "%s:%d: assertion failed\n", __FILE__, __LINE__); \
- fflush (stderr); \
- abort (); \
- } \
- } \
- while (0)
+#include "macros.h"
static int
check (const uint16_t *input, size_t input_length,
@@ -68,13 +55,13 @@ check (const uint16_t *input, size_t input_length,
preallocated = (uint16_t *) malloc (length * sizeof (uint16_t));
result = u16_normalize (UNINORM_NFKD, input, input_length, preallocated, &length);
if (!(result != NULL))
- return 4;
+ return 4;
if (!(result != preallocated))
- return 5;
+ return 5;
if (!(length == expected_length))
- return 6;
+ return 6;
if (!(u16_cmp (result, expected, expected_length) == 0))
- return 7;
+ return 7;
free (result);
free (preallocated);
}
@@ -229,7 +216,7 @@ test_u16_nfkd (void)
static const uint16_t input[] = { 0xFDFA };
static const uint16_t expected[] =
{ 0x0635, 0x0644, 0x0649, 0x0020, 0x0627, 0x0644, 0x0644, 0x0647, 0x0020,
- 0x0639, 0x0644, 0x064A, 0x0647, 0x0020, 0x0648, 0x0633, 0x0644, 0x0645
+ 0x0639, 0x0644, 0x064A, 0x0647, 0x0020, 0x0648, 0x0633, 0x0644, 0x0645
};
ASSERT (check (input, SIZEOF (input), expected, SIZEOF (expected)) == 0);
}
@@ -249,20 +236,20 @@ test_u16_nfkd (void)
{ /* "Grüß Gott. Здравствуйте! x=(-b±sqrt(b²-4ac))/(2a) 日本語,中文,한글" */
static const uint16_t input[] =
{ 'G', 'r', 0x00FC, 0x00DF, ' ', 'G', 'o', 't', 't', '.', ' ',
- 0x0417, 0x0434, 0x0440, 0x0430, 0x0432, 0x0441, 0x0442, 0x0432, 0x0443,
- 0x0439, 0x0442, 0x0435, '!', ' ',
- 'x', '=', '(', '-', 'b', 0x00B1, 's', 'q', 'r', 't', '(', 'b', 0x00B2,
- '-', '4', 'a', 'c', ')', ')', '/', '(', '2', 'a', ')', ' ', ' ',
- 0x65E5, 0x672C, 0x8A9E, ',', 0x4E2D, 0x6587, ',', 0xD55C, 0xAE00, '\n'
+ 0x0417, 0x0434, 0x0440, 0x0430, 0x0432, 0x0441, 0x0442, 0x0432, 0x0443,
+ 0x0439, 0x0442, 0x0435, '!', ' ',
+ 'x', '=', '(', '-', 'b', 0x00B1, 's', 'q', 'r', 't', '(', 'b', 0x00B2,
+ '-', '4', 'a', 'c', ')', ')', '/', '(', '2', 'a', ')', ' ', ' ',
+ 0x65E5, 0x672C, 0x8A9E, ',', 0x4E2D, 0x6587, ',', 0xD55C, 0xAE00, '\n'
};
static const uint16_t expected[] =
{ 'G', 'r', 0x0075, 0x0308, 0x00DF, ' ', 'G', 'o', 't', 't', '.', ' ',
- 0x0417, 0x0434, 0x0440, 0x0430, 0x0432, 0x0441, 0x0442, 0x0432, 0x0443,
- 0x0438, 0x0306, 0x0442, 0x0435, '!', ' ',
- 'x', '=', '(', '-', 'b', 0x00B1, 's', 'q', 'r', 't', '(', 'b', 0x0032,
- '-', '4', 'a', 'c', ')', ')', '/', '(', '2', 'a', ')', ' ', ' ',
- 0x65E5, 0x672C, 0x8A9E, ',', 0x4E2D, 0x6587, ',',
- 0x1112, 0x1161, 0x11AB, 0x1100, 0x1173, 0x11AF, '\n'
+ 0x0417, 0x0434, 0x0440, 0x0430, 0x0432, 0x0441, 0x0442, 0x0432, 0x0443,
+ 0x0438, 0x0306, 0x0442, 0x0435, '!', ' ',
+ 'x', '=', '(', '-', 'b', 0x00B1, 's', 'q', 'r', 't', '(', 'b', 0x0032,
+ '-', '4', 'a', 'c', ')', ')', '/', '(', '2', 'a', ')', ' ', ' ',
+ 0x65E5, 0x672C, 0x8A9E, ',', 0x4E2D, 0x6587, ',',
+ 0x1112, 0x1161, 0x11AB, 0x1100, 0x1173, 0x11AF, '\n'
};
ASSERT (check (input, SIZEOF (input), expected, SIZEOF (expected)) == 0);
}
@@ -279,62 +266,62 @@ test_u16_nfkd (void)
int pass;
for (pass = 0; pass < 3; pass++)
{
- size_t repeat = 1;
- size_t m = 100000;
- uint16_t *input = (uint16_t *) malloc (2 * m * sizeof (uint16_t));
- if (input != NULL)
- {
- uint16_t *expected = input + m;
- size_t m1 = m / 2;
- size_t m2 = (m - 1) / 2;
- /* NB: m1 + m2 == m - 1. */
- uint16_t *p;
- size_t i;
-
- input[0] = 0x0041;
- p = input + 1;
- switch (pass)
- {
- case 0:
- for (i = 0; i < m1; i++)
- *p++ = 0x0319;
- for (i = 0; i < m2; i++)
- *p++ = 0x0300;
- break;
-
- case 1:
- for (i = 0; i < m2; i++)
- *p++ = 0x0300;
- for (i = 0; i < m1; i++)
- *p++ = 0x0319;
- break;
-
- case 2:
- for (i = 0; i < m2; i++)
- {
- *p++ = 0x0319;
- *p++ = 0x0300;
- }
- for (; i < m1; i++)
- *p++ = 0x0319;
- break;
-
- default:
- abort ();
- }
-
- expected[0] = 0x0041;
- p = expected + 1;
- for (i = 0; i < m1; i++)
- *p++ = 0x0319;
- for (i = 0; i < m2; i++)
- *p++ = 0x0300;
-
- for (; repeat > 0; repeat--)
- ASSERT (check (input, m, expected, m) == 0);
-
- free (input);
- }
+ size_t repeat = 1;
+ size_t m = 100000;
+ uint16_t *input = (uint16_t *) malloc (2 * m * sizeof (uint16_t));
+ if (input != NULL)
+ {
+ uint16_t *expected = input + m;
+ size_t m1 = m / 2;
+ size_t m2 = (m - 1) / 2;
+ /* NB: m1 + m2 == m - 1. */
+ uint16_t *p;
+ size_t i;
+
+ input[0] = 0x0041;
+ p = input + 1;
+ switch (pass)
+ {
+ case 0:
+ for (i = 0; i < m1; i++)
+ *p++ = 0x0319;
+ for (i = 0; i < m2; i++)
+ *p++ = 0x0300;
+ break;
+
+ case 1:
+ for (i = 0; i < m2; i++)
+ *p++ = 0x0300;
+ for (i = 0; i < m1; i++)
+ *p++ = 0x0319;
+ break;
+
+ case 2:
+ for (i = 0; i < m2; i++)
+ {
+ *p++ = 0x0319;
+ *p++ = 0x0300;
+ }
+ for (; i < m1; i++)
+ *p++ = 0x0319;
+ break;
+
+ default:
+ abort ();
+ }
+
+ expected[0] = 0x0041;
+ p = expected + 1;
+ for (i = 0; i < m1; i++)
+ *p++ = 0x0319;
+ for (i = 0; i < m2; i++)
+ *p++ = 0x0300;
+
+ for (; repeat > 0; repeat--)
+ ASSERT (check (input, m, expected, m) == 0);
+
+ free (input);
+ }
}
}
}
diff --git a/tests/uninorm/test-u16-normcmp.c b/tests/uninorm/test-u16-normcmp.c
index 3cf947a3..7adcda64 100644
--- a/tests/uninorm/test-u16-normcmp.c
+++ b/tests/uninorm/test-u16-normcmp.c
@@ -1,5 +1,5 @@
/* Test of normalization insensitive comparison of UTF-16 strings.
- Copyright (C) 2009 Free Software Foundation, Inc.
+ Copyright (C) 2009, 2010 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -20,21 +20,7 @@
#include "uninorm.h"
-#include <stdio.h>
-#include <stdlib.h>
-
-#define SIZEOF(array) (sizeof (array) / sizeof (array[0]))
-#define ASSERT(expr) \
- do \
- { \
- if (!(expr)) \
- { \
- fprintf (stderr, "%s:%d: assertion failed\n", __FILE__, __LINE__); \
- fflush (stderr); \
- abort (); \
- } \
- } \
- while (0)
+#include "macros.h"
#include "test-u16-normcmp.h"
diff --git a/tests/uninorm/test-u16-normcmp.h b/tests/uninorm/test-u16-normcmp.h
index ea7def8f..85cbf003 100644
--- a/tests/uninorm/test-u16-normcmp.h
+++ b/tests/uninorm/test-u16-normcmp.h
@@ -1,5 +1,5 @@
/* Test of normalization insensitive comparison of UTF-16 strings.
- Copyright (C) 2009 Free Software Foundation, Inc.
+ Copyright (C) 2009, 2010 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -18,7 +18,7 @@
static void
test_ascii (int (*my_normcmp) (const uint16_t *, size_t, const uint16_t *, size_t, uninorm_t, int *),
- uninorm_t nf)
+ uninorm_t nf)
{
/* Empty string. */
{
diff --git a/tests/uninorm/test-u16-normcoll.c b/tests/uninorm/test-u16-normcoll.c
index d83799dd..ead1561a 100644
--- a/tests/uninorm/test-u16-normcoll.c
+++ b/tests/uninorm/test-u16-normcoll.c
@@ -1,6 +1,6 @@
/* Test of locale dependent, normalization insensitive comparison of
UTF-16 strings.
- Copyright (C) 2009 Free Software Foundation, Inc.
+ Copyright (C) 2009, 2010 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -21,21 +21,7 @@
#include "uninorm.h"
-#include <stdio.h>
-#include <stdlib.h>
-
-#define SIZEOF(array) (sizeof (array) / sizeof (array[0]))
-#define ASSERT(expr) \
- do \
- { \
- if (!(expr)) \
- { \
- fprintf (stderr, "%s:%d: assertion failed\n", __FILE__, __LINE__); \
- fflush (stderr); \
- abort (); \
- } \
- } \
- while (0)
+#include "macros.h"
#include "test-u16-normcmp.h"
int
diff --git a/tests/uninorm/test-u32-nfc-big.c b/tests/uninorm/test-u32-nfc-big.c
index 2a1b611f..dee58060 100644
--- a/tests/uninorm/test-u32-nfc-big.c
+++ b/tests/uninorm/test-u32-nfc-big.c
@@ -1,5 +1,5 @@
/* Test of Unicode compliance of canonical normalization of UTF-32 strings.
- Copyright (C) 2009 Free Software Foundation, Inc.
+ Copyright (C) 2009, 2010 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -18,7 +18,7 @@
#include <config.h>
-#if GNULIB_UNINORM_U32_NORMALIZE
+#if GNULIB_TEST_UNINORM_U32_NORMALIZE
#include "uninorm.h"
@@ -45,8 +45,8 @@ check (const uint32_t *c1, size_t c1_length,
result = u32_normalize (UNINORM_NFC, c1, c1_length, NULL, &length);
if (!(result != NULL
- && length == c2_length
- && u32_cmp (result, c2, c2_length) == 0))
+ && length == c2_length
+ && u32_cmp (result, c2, c2_length) == 0))
return 1;
free (result);
}
@@ -56,8 +56,8 @@ check (const uint32_t *c1, size_t c1_length,
result = u32_normalize (UNINORM_NFC, c2, c2_length, NULL, &length);
if (!(result != NULL
- && length == c2_length
- && u32_cmp (result, c2, c2_length) == 0))
+ && length == c2_length
+ && u32_cmp (result, c2, c2_length) == 0))
return 2;
free (result);
}
@@ -67,8 +67,8 @@ check (const uint32_t *c1, size_t c1_length,
result = u32_normalize (UNINORM_NFC, c3, c3_length, NULL, &length);
if (!(result != NULL
- && length == c2_length
- && u32_cmp (result, c2, c2_length) == 0))
+ && length == c2_length
+ && u32_cmp (result, c2, c2_length) == 0))
return 3;
free (result);
}
@@ -78,8 +78,8 @@ check (const uint32_t *c1, size_t c1_length,
result = u32_normalize (UNINORM_NFC, c4, c4_length, NULL, &length);
if (!(result != NULL
- && length == c4_length
- && u32_cmp (result, c4, c4_length) == 0))
+ && length == c4_length
+ && u32_cmp (result, c4, c4_length) == 0))
return 4;
free (result);
}
@@ -89,8 +89,8 @@ check (const uint32_t *c1, size_t c1_length,
result = u32_normalize (UNINORM_NFC, c5, c5_length, NULL, &length);
if (!(result != NULL
- && length == c4_length
- && u32_cmp (result, c4, c4_length) == 0))
+ && length == c4_length
+ && u32_cmp (result, c4, c4_length) == 0))
return 5;
free (result);
}
diff --git a/tests/uninorm/test-u32-nfc.c b/tests/uninorm/test-u32-nfc.c
index 0d8311cc..b154c8ba 100644
--- a/tests/uninorm/test-u32-nfc.c
+++ b/tests/uninorm/test-u32-nfc.c
@@ -1,5 +1,5 @@
/* Test of canonical normalization of UTF-32 strings.
- Copyright (C) 2009 Free Software Foundation, Inc.
+ Copyright (C) 2009, 2010 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -18,29 +18,16 @@
#include <config.h>
-#if GNULIB_UNINORM_U32_NORMALIZE
+#if GNULIB_TEST_UNINORM_U32_NORMALIZE
#include "uninorm.h"
#include <signal.h>
-#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include "unistr.h"
-
-#define SIZEOF(array) (sizeof (array) / sizeof (array[0]))
-#define ASSERT(expr) \
- do \
- { \
- if (!(expr)) \
- { \
- fprintf (stderr, "%s:%d: assertion failed\n", __FILE__, __LINE__); \
- fflush (stderr); \
- abort (); \
- } \
- } \
- while (0)
+#include "macros.h"
static int
check (const uint32_t *input, size_t input_length,
@@ -68,13 +55,13 @@ check (const uint32_t *input, size_t input_length,
preallocated = (uint32_t *) malloc (length * sizeof (uint32_t));
result = u32_normalize (UNINORM_NFC, input, input_length, preallocated, &length);
if (!(result != NULL))
- return 4;
+ return 4;
if (!(result != preallocated))
- return 5;
+ return 5;
if (!(length == expected_length))
- return 6;
+ return 6;
if (!(u32_cmp (result, expected, expected_length) == 0))
- return 7;
+ return 7;
free (result);
free (preallocated);
}
@@ -241,20 +228,20 @@ test_u32_nfc (void)
{ /* "Grüß Gott. Здравствуйте! x=(-b±sqrt(b²-4ac))/(2a) 日本語,中文,한글" */
static const uint32_t input[] =
{ 'G', 'r', 0x00FC, 0x00DF, ' ', 'G', 'o', 't', 't', '.', ' ',
- 0x0417, 0x0434, 0x0440, 0x0430, 0x0432, 0x0441, 0x0442, 0x0432, 0x0443,
- 0x0439, 0x0442, 0x0435, '!', ' ',
- 'x', '=', '(', '-', 'b', 0x00B1, 's', 'q', 'r', 't', '(', 'b', 0x00B2,
- '-', '4', 'a', 'c', ')', ')', '/', '(', '2', 'a', ')', ' ', ' ',
- 0x65E5, 0x672C, 0x8A9E, ',', 0x4E2D, 0x6587, ',', 0xD55C, 0xAE00, '\n'
+ 0x0417, 0x0434, 0x0440, 0x0430, 0x0432, 0x0441, 0x0442, 0x0432, 0x0443,
+ 0x0439, 0x0442, 0x0435, '!', ' ',
+ 'x', '=', '(', '-', 'b', 0x00B1, 's', 'q', 'r', 't', '(', 'b', 0x00B2,
+ '-', '4', 'a', 'c', ')', ')', '/', '(', '2', 'a', ')', ' ', ' ',
+ 0x65E5, 0x672C, 0x8A9E, ',', 0x4E2D, 0x6587, ',', 0xD55C, 0xAE00, '\n'
};
static const uint32_t decomposed[] =
{ 'G', 'r', 0x0075, 0x0308, 0x00DF, ' ', 'G', 'o', 't', 't', '.', ' ',
- 0x0417, 0x0434, 0x0440, 0x0430, 0x0432, 0x0441, 0x0442, 0x0432, 0x0443,
- 0x0438, 0x0306, 0x0442, 0x0435, '!', ' ',
- 'x', '=', '(', '-', 'b', 0x00B1, 's', 'q', 'r', 't', '(', 'b', 0x00B2,
- '-', '4', 'a', 'c', ')', ')', '/', '(', '2', 'a', ')', ' ', ' ',
- 0x65E5, 0x672C, 0x8A9E, ',', 0x4E2D, 0x6587, ',',
- 0x1112, 0x1161, 0x11AB, 0x1100, 0x1173, 0x11AF, '\n'
+ 0x0417, 0x0434, 0x0440, 0x0430, 0x0432, 0x0441, 0x0442, 0x0432, 0x0443,
+ 0x0438, 0x0306, 0x0442, 0x0435, '!', ' ',
+ 'x', '=', '(', '-', 'b', 0x00B1, 's', 'q', 'r', 't', '(', 'b', 0x00B2,
+ '-', '4', 'a', 'c', ')', ')', '/', '(', '2', 'a', ')', ' ', ' ',
+ 0x65E5, 0x672C, 0x8A9E, ',', 0x4E2D, 0x6587, ',',
+ 0x1112, 0x1161, 0x11AB, 0x1100, 0x1173, 0x11AF, '\n'
};
ASSERT (check (input, SIZEOF (input), input, SIZEOF (input)) == 0);
ASSERT (check (decomposed, SIZEOF (decomposed), input, SIZEOF (input)) == 0);
@@ -272,65 +259,65 @@ test_u32_nfc (void)
int pass;
for (pass = 0; pass < 3; pass++)
{
- size_t repeat = 1;
- size_t m = 100000;
- uint32_t *input = (uint32_t *) malloc (2 * m * sizeof (uint32_t));
- if (input != NULL)
- {
- uint32_t *expected = input + m;
- size_t m1 = m / 2;
- size_t m2 = (m - 1) / 2;
- /* NB: m1 + m2 == m - 1. */
- uint32_t *p;
- size_t i;
-
- input[0] = 0x0041;
- p = input + 1;
- switch (pass)
- {
- case 0:
- for (i = 0; i < m1; i++)
- *p++ = 0x0319;
- for (i = 0; i < m2; i++)
- *p++ = 0x0300;
- break;
-
- case 1:
- for (i = 0; i < m2; i++)
- *p++ = 0x0300;
- for (i = 0; i < m1; i++)
- *p++ = 0x0319;
- break;
-
- case 2:
- for (i = 0; i < m2; i++)
- {
- *p++ = 0x0319;
- *p++ = 0x0300;
- }
- for (; i < m1; i++)
- *p++ = 0x0319;
- break;
-
- default:
- abort ();
- }
-
- expected[0] = 0x00C0;
- p = expected + 1;
- for (i = 0; i < m1; i++)
- *p++ = 0x0319;
- for (i = 0; i < m2 - 1; i++)
- *p++ = 0x0300;
-
- for (; repeat > 0; repeat--)
- {
- ASSERT (check (input, m, expected, m - 1) == 0);
- ASSERT (check (expected, m - 1, expected, m - 1) == 0);
- }
-
- free (input);
- }
+ size_t repeat = 1;
+ size_t m = 100000;
+ uint32_t *input = (uint32_t *) malloc (2 * m * sizeof (uint32_t));
+ if (input != NULL)
+ {
+ uint32_t *expected = input + m;
+ size_t m1 = m / 2;
+ size_t m2 = (m - 1) / 2;
+ /* NB: m1 + m2 == m - 1. */
+ uint32_t *p;
+ size_t i;
+
+ input[0] = 0x0041;
+ p = input + 1;
+ switch (pass)
+ {
+ case 0:
+ for (i = 0; i < m1; i++)
+ *p++ = 0x0319;
+ for (i = 0; i < m2; i++)
+ *p++ = 0x0300;
+ break;
+
+ case 1:
+ for (i = 0; i < m2; i++)
+ *p++ = 0x0300;
+ for (i = 0; i < m1; i++)
+ *p++ = 0x0319;
+ break;
+
+ case 2:
+ for (i = 0; i < m2; i++)
+ {
+ *p++ = 0x0319;
+ *p++ = 0x0300;
+ }
+ for (; i < m1; i++)
+ *p++ = 0x0319;
+ break;
+
+ default:
+ abort ();
+ }
+
+ expected[0] = 0x00C0;
+ p = expected + 1;
+ for (i = 0; i < m1; i++)
+ *p++ = 0x0319;
+ for (i = 0; i < m2 - 1; i++)
+ *p++ = 0x0300;
+
+ for (; repeat > 0; repeat--)
+ {
+ ASSERT (check (input, m, expected, m - 1) == 0);
+ ASSERT (check (expected, m - 1, expected, m - 1) == 0);
+ }
+
+ free (input);
+ }
}
}
}
diff --git a/tests/uninorm/test-u32-nfd-big.c b/tests/uninorm/test-u32-nfd-big.c
index 9bfd0d89..ccc12918 100644
--- a/tests/uninorm/test-u32-nfd-big.c
+++ b/tests/uninorm/test-u32-nfd-big.c
@@ -1,5 +1,5 @@
/* Test of Unicode compliance of canonical decomposition of UTF-32 strings.
- Copyright (C) 2009 Free Software Foundation, Inc.
+ Copyright (C) 2009, 2010 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -18,7 +18,7 @@
#include <config.h>
-#if GNULIB_UNINORM_U32_NORMALIZE
+#if GNULIB_TEST_UNINORM_U32_NORMALIZE
#include "uninorm.h"
@@ -45,8 +45,8 @@ check (const uint32_t *c1, size_t c1_length,
result = u32_normalize (UNINORM_NFD, c1, c1_length, NULL, &length);
if (!(result != NULL
- && length == c3_length
- && u32_cmp (result, c3, c3_length) == 0))
+ && length == c3_length
+ && u32_cmp (result, c3, c3_length) == 0))
return 1;
free (result);
}
@@ -56,8 +56,8 @@ check (const uint32_t *c1, size_t c1_length,
result = u32_normalize (UNINORM_NFD, c2, c2_length, NULL, &length);
if (!(result != NULL
- && length == c3_length
- && u32_cmp (result, c3, c3_length) == 0))
+ && length == c3_length
+ && u32_cmp (result, c3, c3_length) == 0))
return 2;
free (result);
}
@@ -67,8 +67,8 @@ check (const uint32_t *c1, size_t c1_length,
result = u32_normalize (UNINORM_NFD, c3, c3_length, NULL, &length);
if (!(result != NULL
- && length == c3_length
- && u32_cmp (result, c3, c3_length) == 0))
+ && length == c3_length
+ && u32_cmp (result, c3, c3_length) == 0))
return 3;
free (result);
}
@@ -78,8 +78,8 @@ check (const uint32_t *c1, size_t c1_length,
result = u32_normalize (UNINORM_NFD, c4, c4_length, NULL, &length);
if (!(result != NULL
- && length == c5_length
- && u32_cmp (result, c5, c5_length) == 0))
+ && length == c5_length
+ && u32_cmp (result, c5, c5_length) == 0))
return 4;
free (result);
}
@@ -89,8 +89,8 @@ check (const uint32_t *c1, size_t c1_length,
result = u32_normalize (UNINORM_NFD, c5, c5_length, NULL, &length);
if (!(result != NULL
- && length == c5_length
- && u32_cmp (result, c5, c5_length) == 0))
+ && length == c5_length
+ && u32_cmp (result, c5, c5_length) == 0))
return 5;
free (result);
}
diff --git a/tests/uninorm/test-u32-nfd.c b/tests/uninorm/test-u32-nfd.c
index f7b2d8df..58c97b2b 100644
--- a/tests/uninorm/test-u32-nfd.c
+++ b/tests/uninorm/test-u32-nfd.c
@@ -1,5 +1,5 @@
/* Test of canonical decomposition of UTF-32 strings.
- Copyright (C) 2009 Free Software Foundation, Inc.
+ Copyright (C) 2009, 2010 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -18,29 +18,16 @@
#include <config.h>
-#if GNULIB_UNINORM_U32_NORMALIZE
+#if GNULIB_TEST_UNINORM_U32_NORMALIZE
#include "uninorm.h"
#include <signal.h>
-#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include "unistr.h"
-
-#define SIZEOF(array) (sizeof (array) / sizeof (array[0]))
-#define ASSERT(expr) \
- do \
- { \
- if (!(expr)) \
- { \
- fprintf (stderr, "%s:%d: assertion failed\n", __FILE__, __LINE__); \
- fflush (stderr); \
- abort (); \
- } \
- } \
- while (0)
+#include "macros.h"
static int
check (const uint32_t *input, size_t input_length,
@@ -68,13 +55,13 @@ check (const uint32_t *input, size_t input_length,
preallocated = (uint32_t *) malloc (length * sizeof (uint32_t));
result = u32_normalize (UNINORM_NFD, input, input_length, preallocated, &length);
if (!(result != NULL))
- return 4;
+ return 4;
if (!(result != preallocated))
- return 5;
+ return 5;
if (!(length == expected_length))
- return 6;
+ return 6;
if (!(u32_cmp (result, expected, expected_length) == 0))
- return 7;
+ return 7;
free (result);
free (preallocated);
}
@@ -229,20 +216,20 @@ test_u32_nfd (void)
{ /* "Grüß Gott. Здравствуйте! x=(-b±sqrt(b²-4ac))/(2a) 日本語,中文,한글" */
static const uint32_t input[] =
{ 'G', 'r', 0x00FC, 0x00DF, ' ', 'G', 'o', 't', 't', '.', ' ',
- 0x0417, 0x0434, 0x0440, 0x0430, 0x0432, 0x0441, 0x0442, 0x0432, 0x0443,
- 0x0439, 0x0442, 0x0435, '!', ' ',
- 'x', '=', '(', '-', 'b', 0x00B1, 's', 'q', 'r', 't', '(', 'b', 0x00B2,
- '-', '4', 'a', 'c', ')', ')', '/', '(', '2', 'a', ')', ' ', ' ',
- 0x65E5, 0x672C, 0x8A9E, ',', 0x4E2D, 0x6587, ',', 0xD55C, 0xAE00, '\n'
+ 0x0417, 0x0434, 0x0440, 0x0430, 0x0432, 0x0441, 0x0442, 0x0432, 0x0443,
+ 0x0439, 0x0442, 0x0435, '!', ' ',
+ 'x', '=', '(', '-', 'b', 0x00B1, 's', 'q', 'r', 't', '(', 'b', 0x00B2,
+ '-', '4', 'a', 'c', ')', ')', '/', '(', '2', 'a', ')', ' ', ' ',
+ 0x65E5, 0x672C, 0x8A9E, ',', 0x4E2D, 0x6587, ',', 0xD55C, 0xAE00, '\n'
};
static const uint32_t expected[] =
{ 'G', 'r', 0x0075, 0x0308, 0x00DF, ' ', 'G', 'o', 't', 't', '.', ' ',
- 0x0417, 0x0434, 0x0440, 0x0430, 0x0432, 0x0441, 0x0442, 0x0432, 0x0443,
- 0x0438, 0x0306, 0x0442, 0x0435, '!', ' ',
- 'x', '=', '(', '-', 'b', 0x00B1, 's', 'q', 'r', 't', '(', 'b', 0x00B2,
- '-', '4', 'a', 'c', ')', ')', '/', '(', '2', 'a', ')', ' ', ' ',
- 0x65E5, 0x672C, 0x8A9E, ',', 0x4E2D, 0x6587, ',',
- 0x1112, 0x1161, 0x11AB, 0x1100, 0x1173, 0x11AF, '\n'
+ 0x0417, 0x0434, 0x0440, 0x0430, 0x0432, 0x0441, 0x0442, 0x0432, 0x0443,
+ 0x0438, 0x0306, 0x0442, 0x0435, '!', ' ',
+ 'x', '=', '(', '-', 'b', 0x00B1, 's', 'q', 'r', 't', '(', 'b', 0x00B2,
+ '-', '4', 'a', 'c', ')', ')', '/', '(', '2', 'a', ')', ' ', ' ',
+ 0x65E5, 0x672C, 0x8A9E, ',', 0x4E2D, 0x6587, ',',
+ 0x1112, 0x1161, 0x11AB, 0x1100, 0x1173, 0x11AF, '\n'
};
ASSERT (check (input, SIZEOF (input), expected, SIZEOF (expected)) == 0);
}
@@ -259,62 +246,62 @@ test_u32_nfd (void)
int pass;
for (pass = 0; pass < 3; pass++)
{
- size_t repeat = 1;
- size_t m = 100000;
- uint32_t *input = (uint32_t *) malloc (2 * m * sizeof (uint32_t));
- if (input != NULL)
- {
- uint32_t *expected = input + m;
- size_t m1 = m / 2;
- size_t m2 = (m - 1) / 2;
- /* NB: m1 + m2 == m - 1. */
- uint32_t *p;
- size_t i;
-
- input[0] = 0x0041;
- p = input + 1;
- switch (pass)
- {
- case 0:
- for (i = 0; i < m1; i++)
- *p++ = 0x0319;
- for (i = 0; i < m2; i++)
- *p++ = 0x0300;
- break;
-
- case 1:
- for (i = 0; i < m2; i++)
- *p++ = 0x0300;
- for (i = 0; i < m1; i++)
- *p++ = 0x0319;
- break;
-
- case 2:
- for (i = 0; i < m2; i++)
- {
- *p++ = 0x0319;
- *p++ = 0x0300;
- }
- for (; i < m1; i++)
- *p++ = 0x0319;
- break;
-
- default:
- abort ();
- }
-
- expected[0] = 0x0041;
- p = expected + 1;
- for (i = 0; i < m1; i++)
- *p++ = 0x0319;
- for (i = 0; i < m2; i++)
- *p++ = 0x0300;
-
- for (; repeat > 0; repeat--)
- ASSERT (check (input, m, expected, m) == 0);
-
- free (input);
- }
+ size_t repeat = 1;
+ size_t m = 100000;
+ uint32_t *input = (uint32_t *) malloc (2 * m * sizeof (uint32_t));
+ if (input != NULL)
+ {
+ uint32_t *expected = input + m;
+ size_t m1 = m / 2;
+ size_t m2 = (m - 1) / 2;
+ /* NB: m1 + m2 == m - 1. */
+ uint32_t *p;
+ size_t i;
+
+ input[0] = 0x0041;
+ p = input + 1;
+ switch (pass)
+ {
+ case 0:
+ for (i = 0; i < m1; i++)
+ *p++ = 0x0319;
+ for (i = 0; i < m2; i++)
+ *p++ = 0x0300;
+ break;
+
+ case 1:
+ for (i = 0; i < m2; i++)
+ *p++ = 0x0300;
+ for (i = 0; i < m1; i++)
+ *p++ = 0x0319;
+ break;
+
+ case 2:
+ for (i = 0; i < m2; i++)
+ {
+ *p++ = 0x0319;
+ *p++ = 0x0300;
+ }
+ for (; i < m1; i++)
+ *p++ = 0x0319;
+ break;
+
+ default:
+ abort ();
+ }
+
+ expected[0] = 0x0041;
+ p = expected + 1;
+ for (i = 0; i < m1; i++)
+ *p++ = 0x0319;
+ for (i = 0; i < m2; i++)
+ *p++ = 0x0300;
+
+ for (; repeat > 0; repeat--)
+ ASSERT (check (input, m, expected, m) == 0);
+
+ free (input);
+ }
}
}
}
diff --git a/tests/uninorm/test-u32-nfkc-big.c b/tests/uninorm/test-u32-nfkc-big.c
index 340fe65b..7827d33b 100644
--- a/tests/uninorm/test-u32-nfkc-big.c
+++ b/tests/uninorm/test-u32-nfkc-big.c
@@ -1,5 +1,5 @@
/* Test of Unicode compliance of compatibility normalization of UTF-32 strings.
- Copyright (C) 2009 Free Software Foundation, Inc.
+ Copyright (C) 2009, 2010 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -18,7 +18,7 @@
#include <config.h>
-#if GNULIB_UNINORM_U32_NORMALIZE
+#if GNULIB_TEST_UNINORM_U32_NORMALIZE
#include "uninorm.h"
@@ -42,8 +42,8 @@ check (const uint32_t *c1, size_t c1_length,
result = u32_normalize (UNINORM_NFKC, c1, c1_length, NULL, &length);
if (!(result != NULL
- && length == c4_length
- && u32_cmp (result, c4, c4_length) == 0))
+ && length == c4_length
+ && u32_cmp (result, c4, c4_length) == 0))
return 1;
free (result);
}
@@ -53,8 +53,8 @@ check (const uint32_t *c1, size_t c1_length,
result = u32_normalize (UNINORM_NFKC, c2, c2_length, NULL, &length);
if (!(result != NULL
- && length == c4_length
- && u32_cmp (result, c4, c4_length) == 0))
+ && length == c4_length
+ && u32_cmp (result, c4, c4_length) == 0))
return 2;
free (result);
}
@@ -64,8 +64,8 @@ check (const uint32_t *c1, size_t c1_length,
result = u32_normalize (UNINORM_NFKC, c3, c3_length, NULL, &length);
if (!(result != NULL
- && length == c4_length
- && u32_cmp (result, c4, c4_length) == 0))
+ && length == c4_length
+ && u32_cmp (result, c4, c4_length) == 0))
return 3;
free (result);
}
@@ -75,8 +75,8 @@ check (const uint32_t *c1, size_t c1_length,
result = u32_normalize (UNINORM_NFKC, c4, c4_length, NULL, &length);
if (!(result != NULL
- && length == c4_length
- && u32_cmp (result, c4, c4_length) == 0))
+ && length == c4_length
+ && u32_cmp (result, c4, c4_length) == 0))
return 4;
free (result);
}
@@ -86,8 +86,8 @@ check (const uint32_t *c1, size_t c1_length,
result = u32_normalize (UNINORM_NFKC, c5, c5_length, NULL, &length);
if (!(result != NULL
- && length == c4_length
- && u32_cmp (result, c4, c4_length) == 0))
+ && length == c4_length
+ && u32_cmp (result, c4, c4_length) == 0))
return 5;
free (result);
}
diff --git a/tests/uninorm/test-u32-nfkc.c b/tests/uninorm/test-u32-nfkc.c
index 75f7e825..eb4d3ce7 100644
--- a/tests/uninorm/test-u32-nfkc.c
+++ b/tests/uninorm/test-u32-nfkc.c
@@ -1,5 +1,5 @@
/* Test of compatibility normalization of UTF-32 strings.
- Copyright (C) 2009 Free Software Foundation, Inc.
+ Copyright (C) 2009, 2010 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -18,29 +18,16 @@
#include <config.h>
-#if GNULIB_UNINORM_U32_NORMALIZE
+#if GNULIB_TEST_UNINORM_U32_NORMALIZE
#include "uninorm.h"
#include <signal.h>
-#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include "unistr.h"
-
-#define SIZEOF(array) (sizeof (array) / sizeof (array[0]))
-#define ASSERT(expr) \
- do \
- { \
- if (!(expr)) \
- { \
- fprintf (stderr, "%s:%d: assertion failed\n", __FILE__, __LINE__); \
- fflush (stderr); \
- abort (); \
- } \
- } \
- while (0)
+#include "macros.h"
static int
check (const uint32_t *input, size_t input_length,
@@ -68,13 +55,13 @@ check (const uint32_t *input, size_t input_length,
preallocated = (uint32_t *) malloc (length * sizeof (uint32_t));
result = u32_normalize (UNINORM_NFKC, input, input_length, preallocated, &length);
if (!(result != NULL))
- return 4;
+ return 4;
if (!(result != preallocated))
- return 5;
+ return 5;
if (!(length == expected_length))
- return 6;
+ return 6;
if (!(u32_cmp (result, expected, expected_length) == 0))
- return 7;
+ return 7;
free (result);
free (preallocated);
}
@@ -257,7 +244,7 @@ test_u32_nfkc (void)
static const uint32_t input[] = { 0xFDFA };
static const uint32_t decomposed[] =
{ 0x0635, 0x0644, 0x0649, 0x0020, 0x0627, 0x0644, 0x0644, 0x0647, 0x0020,
- 0x0639, 0x0644, 0x064A, 0x0647, 0x0020, 0x0648, 0x0633, 0x0644, 0x0645
+ 0x0639, 0x0644, 0x064A, 0x0647, 0x0020, 0x0648, 0x0633, 0x0644, 0x0645
};
ASSERT (check (input, SIZEOF (input), decomposed, SIZEOF (decomposed)) == 0);
ASSERT (check (decomposed, SIZEOF (decomposed), decomposed, SIZEOF (decomposed)) == 0);
@@ -280,28 +267,28 @@ test_u32_nfkc (void)
{ /* "Grüß Gott. Здравствуйте! x=(-b±sqrt(b²-4ac))/(2a) 日本語,中文,한글" */
static const uint32_t input[] =
{ 'G', 'r', 0x00FC, 0x00DF, ' ', 'G', 'o', 't', 't', '.', ' ',
- 0x0417, 0x0434, 0x0440, 0x0430, 0x0432, 0x0441, 0x0442, 0x0432, 0x0443,
- 0x0439, 0x0442, 0x0435, '!', ' ',
- 'x', '=', '(', '-', 'b', 0x00B1, 's', 'q', 'r', 't', '(', 'b', 0x00B2,
- '-', '4', 'a', 'c', ')', ')', '/', '(', '2', 'a', ')', ' ', ' ',
- 0x65E5, 0x672C, 0x8A9E, ',', 0x4E2D, 0x6587, ',', 0xD55C, 0xAE00, '\n'
+ 0x0417, 0x0434, 0x0440, 0x0430, 0x0432, 0x0441, 0x0442, 0x0432, 0x0443,
+ 0x0439, 0x0442, 0x0435, '!', ' ',
+ 'x', '=', '(', '-', 'b', 0x00B1, 's', 'q', 'r', 't', '(', 'b', 0x00B2,
+ '-', '4', 'a', 'c', ')', ')', '/', '(', '2', 'a', ')', ' ', ' ',
+ 0x65E5, 0x672C, 0x8A9E, ',', 0x4E2D, 0x6587, ',', 0xD55C, 0xAE00, '\n'
};
static const uint32_t decomposed[] =
{ 'G', 'r', 0x0075, 0x0308, 0x00DF, ' ', 'G', 'o', 't', 't', '.', ' ',
- 0x0417, 0x0434, 0x0440, 0x0430, 0x0432, 0x0441, 0x0442, 0x0432, 0x0443,
- 0x0438, 0x0306, 0x0442, 0x0435, '!', ' ',
- 'x', '=', '(', '-', 'b', 0x00B1, 's', 'q', 'r', 't', '(', 'b', 0x0032,
- '-', '4', 'a', 'c', ')', ')', '/', '(', '2', 'a', ')', ' ', ' ',
- 0x65E5, 0x672C, 0x8A9E, ',', 0x4E2D, 0x6587, ',',
- 0x1112, 0x1161, 0x11AB, 0x1100, 0x1173, 0x11AF, '\n'
+ 0x0417, 0x0434, 0x0440, 0x0430, 0x0432, 0x0441, 0x0442, 0x0432, 0x0443,
+ 0x0438, 0x0306, 0x0442, 0x0435, '!', ' ',
+ 'x', '=', '(', '-', 'b', 0x00B1, 's', 'q', 'r', 't', '(', 'b', 0x0032,
+ '-', '4', 'a', 'c', ')', ')', '/', '(', '2', 'a', ')', ' ', ' ',
+ 0x65E5, 0x672C, 0x8A9E, ',', 0x4E2D, 0x6587, ',',
+ 0x1112, 0x1161, 0x11AB, 0x1100, 0x1173, 0x11AF, '\n'
};
static const uint32_t expected[] =
{ 'G', 'r', 0x00FC, 0x00DF, ' ', 'G', 'o', 't', 't', '.', ' ',
- 0x0417, 0x0434, 0x0440, 0x0430, 0x0432, 0x0441, 0x0442, 0x0432, 0x0443,
- 0x0439, 0x0442, 0x0435, '!', ' ',
- 'x', '=', '(', '-', 'b', 0x00B1, 's', 'q', 'r', 't', '(', 'b', 0x0032,
- '-', '4', 'a', 'c', ')', ')', '/', '(', '2', 'a', ')', ' ', ' ',
- 0x65E5, 0x672C, 0x8A9E, ',', 0x4E2D, 0x6587, ',', 0xD55C, 0xAE00, '\n'
+ 0x0417, 0x0434, 0x0440, 0x0430, 0x0432, 0x0441, 0x0442, 0x0432, 0x0443,
+ 0x0439, 0x0442, 0x0435, '!', ' ',
+ 'x', '=', '(', '-', 'b', 0x00B1, 's', 'q', 'r', 't', '(', 'b', 0x0032,
+ '-', '4', 'a', 'c', ')', ')', '/', '(', '2', 'a', ')', ' ', ' ',
+ 0x65E5, 0x672C, 0x8A9E, ',', 0x4E2D, 0x6587, ',', 0xD55C, 0xAE00, '\n'
};
ASSERT (check (input, SIZEOF (input), expected, SIZEOF (expected)) == 0);
ASSERT (check (decomposed, SIZEOF (decomposed), expected, SIZEOF (expected)) == 0);
@@ -320,65 +307,65 @@ test_u32_nfkc (void)
int pass;
for (pass = 0; pass < 3; pass++)
{
- size_t repeat = 1;
- size_t m = 100000;
- uint32_t *input = (uint32_t *) malloc (2 * m * sizeof (uint32_t));
- if (input != NULL)
- {
- uint32_t *expected = input + m;
- size_t m1 = m / 2;
- size_t m2 = (m - 1) / 2;
- /* NB: m1 + m2 == m - 1. */
- uint32_t *p;
- size_t i;
-
- input[0] = 0x0041;
- p = input + 1;
- switch (pass)
- {
- case 0:
- for (i = 0; i < m1; i++)
- *p++ = 0x0319;
- for (i = 0; i < m2; i++)
- *p++ = 0x0300;
- break;
-
- case 1:
- for (i = 0; i < m2; i++)
- *p++ = 0x0300;
- for (i = 0; i < m1; i++)
- *p++ = 0x0319;
- break;
-
- case 2:
- for (i = 0; i < m2; i++)
- {
- *p++ = 0x0319;
- *p++ = 0x0300;
- }
- for (; i < m1; i++)
- *p++ = 0x0319;
- break;
-
- default:
- abort ();
- }
-
- expected[0] = 0x00C0;
- p = expected + 1;
- for (i = 0; i < m1; i++)
- *p++ = 0x0319;
- for (i = 0; i < m2 - 1; i++)
- *p++ = 0x0300;
-
- for (; repeat > 0; repeat--)
- {
- ASSERT (check (input, m, expected, m - 1) == 0);
- ASSERT (check (expected, m - 1, expected, m - 1) == 0);
- }
-
- free (input);
- }
+ size_t repeat = 1;
+ size_t m = 100000;
+ uint32_t *input = (uint32_t *) malloc (2 * m * sizeof (uint32_t));
+ if (input != NULL)
+ {
+ uint32_t *expected = input + m;
+ size_t m1 = m / 2;
+ size_t m2 = (m - 1) / 2;
+ /* NB: m1 + m2 == m - 1. */
+ uint32_t *p;
+ size_t i;
+
+ input[0] = 0x0041;
+ p = input + 1;
+ switch (pass)
+ {
+ case 0:
+ for (i = 0; i < m1; i++)
+ *p++ = 0x0319;
+ for (i = 0; i < m2; i++)
+ *p++ = 0x0300;
+ break;
+
+ case 1:
+ for (i = 0; i < m2; i++)
+ *p++ = 0x0300;
+ for (i = 0; i < m1; i++)
+ *p++ = 0x0319;
+ break;
+
+ case 2:
+ for (i = 0; i < m2; i++)
+ {
+ *p++ = 0x0319;
+ *p++ = 0x0300;
+ }
+ for (; i < m1; i++)
+ *p++ = 0x0319;
+ break;
+
+ default:
+ abort ();
+ }
+
+ expected[0] = 0x00C0;
+ p = expected + 1;
+ for (i = 0; i < m1; i++)
+ *p++ = 0x0319;
+ for (i = 0; i < m2 - 1; i++)
+ *p++ = 0x0300;
+
+ for (; repeat > 0; repeat--)
+ {
+ ASSERT (check (input, m, expected, m - 1) == 0);
+ ASSERT (check (expected, m - 1, expected, m - 1) == 0);
+ }
+
+ free (input);
+ }
}
}
}
diff --git a/tests/uninorm/test-u32-nfkd-big.c b/tests/uninorm/test-u32-nfkd-big.c
index e7c1b4f3..14232c55 100644
--- a/tests/uninorm/test-u32-nfkd-big.c
+++ b/tests/uninorm/test-u32-nfkd-big.c
@@ -1,5 +1,5 @@
/* Test of Unicode compliance of compatibility decomposition of UTF-32 strings.
- Copyright (C) 2009 Free Software Foundation, Inc.
+ Copyright (C) 2009, 2010 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -18,7 +18,7 @@
#include <config.h>
-#if GNULIB_UNINORM_U32_NORMALIZE
+#if GNULIB_TEST_UNINORM_U32_NORMALIZE
#include "uninorm.h"
@@ -42,8 +42,8 @@ check (const uint32_t *c1, size_t c1_length,
result = u32_normalize (UNINORM_NFKD, c1, c1_length, NULL, &length);
if (!(result != NULL
- && length == c5_length
- && u32_cmp (result, c5, c5_length) == 0))
+ && length == c5_length
+ && u32_cmp (result, c5, c5_length) == 0))
return 1;
free (result);
}
@@ -53,8 +53,8 @@ check (const uint32_t *c1, size_t c1_length,
result = u32_normalize (UNINORM_NFKD, c2, c2_length, NULL, &length);
if (!(result != NULL
- && length == c5_length
- && u32_cmp (result, c5, c5_length) == 0))
+ && length == c5_length
+ && u32_cmp (result, c5, c5_length) == 0))
return 2;
free (result);
}
@@ -64,8 +64,8 @@ check (const uint32_t *c1, size_t c1_length,
result = u32_normalize (UNINORM_NFKD, c3, c3_length, NULL, &length);
if (!(result != NULL
- && length == c5_length
- && u32_cmp (result, c5, c5_length) == 0))
+ && length == c5_length
+ && u32_cmp (result, c5, c5_length) == 0))
return 3;
free (result);
}
@@ -75,8 +75,8 @@ check (const uint32_t *c1, size_t c1_length,
result = u32_normalize (UNINORM_NFKD, c4, c4_length, NULL, &length);
if (!(result != NULL
- && length == c5_length
- && u32_cmp (result, c5, c5_length) == 0))
+ && length == c5_length
+ && u32_cmp (result, c5, c5_length) == 0))
return 4;
free (result);
}
@@ -86,8 +86,8 @@ check (const uint32_t *c1, size_t c1_length,
result = u32_normalize (UNINORM_NFKD, c5, c5_length, NULL, &length);
if (!(result != NULL
- && length == c5_length
- && u32_cmp (result, c5, c5_length) == 0))
+ && length == c5_length
+ && u32_cmp (result, c5, c5_length) == 0))
return 5;
free (result);
}
diff --git a/tests/uninorm/test-u32-nfkd.c b/tests/uninorm/test-u32-nfkd.c
index d3de7f76..b98f6512 100644
--- a/tests/uninorm/test-u32-nfkd.c
+++ b/tests/uninorm/test-u32-nfkd.c
@@ -1,5 +1,5 @@
/* Test of compatibility decomposition of UTF-32 strings.
- Copyright (C) 2009 Free Software Foundation, Inc.
+ Copyright (C) 2009, 2010 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -18,29 +18,16 @@
#include <config.h>
-#if GNULIB_UNINORM_U32_NORMALIZE
+#if GNULIB_TEST_UNINORM_U32_NORMALIZE
#include "uninorm.h"
#include <signal.h>
-#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include "unistr.h"
-
-#define SIZEOF(array) (sizeof (array) / sizeof (array[0]))
-#define ASSERT(expr) \
- do \
- { \
- if (!(expr)) \
- { \
- fprintf (stderr, "%s:%d: assertion failed\n", __FILE__, __LINE__); \
- fflush (stderr); \
- abort (); \
- } \
- } \
- while (0)
+#include "macros.h"
static int
check (const uint32_t *input, size_t input_length,
@@ -68,13 +55,13 @@ check (const uint32_t *input, size_t input_length,
preallocated = (uint32_t *) malloc (length * sizeof (uint32_t));
result = u32_normalize (UNINORM_NFKD, input, input_length, preallocated, &length);
if (!(result != NULL))
- return 4;
+ return 4;
if (!(result != preallocated))
- return 5;
+ return 5;
if (!(length == expected_length))
- return 6;
+ return 6;
if (!(u32_cmp (result, expected, expected_length) == 0))
- return 7;
+ return 7;
free (result);
free (preallocated);
}
@@ -229,7 +216,7 @@ test_u32_nfkd (void)
static const uint32_t input[] = { 0xFDFA };
static const uint32_t expected[] =
{ 0x0635, 0x0644, 0x0649, 0x0020, 0x0627, 0x0644, 0x0644, 0x0647, 0x0020,
- 0x0639, 0x0644, 0x064A, 0x0647, 0x0020, 0x0648, 0x0633, 0x0644, 0x0645
+ 0x0639, 0x0644, 0x064A, 0x0647, 0x0020, 0x0648, 0x0633, 0x0644, 0x0645
};
ASSERT (check (input, SIZEOF (input), expected, SIZEOF (expected)) == 0);
}
@@ -249,20 +236,20 @@ test_u32_nfkd (void)
{ /* "Grüß Gott. Здравствуйте! x=(-b±sqrt(b²-4ac))/(2a) 日本語,中文,한글" */
static const uint32_t input[] =
{ 'G', 'r', 0x00FC, 0x00DF, ' ', 'G', 'o', 't', 't', '.', ' ',
- 0x0417, 0x0434, 0x0440, 0x0430, 0x0432, 0x0441, 0x0442, 0x0432, 0x0443,
- 0x0439, 0x0442, 0x0435, '!', ' ',
- 'x', '=', '(', '-', 'b', 0x00B1, 's', 'q', 'r', 't', '(', 'b', 0x00B2,
- '-', '4', 'a', 'c', ')', ')', '/', '(', '2', 'a', ')', ' ', ' ',
- 0x65E5, 0x672C, 0x8A9E, ',', 0x4E2D, 0x6587, ',', 0xD55C, 0xAE00, '\n'
+ 0x0417, 0x0434, 0x0440, 0x0430, 0x0432, 0x0441, 0x0442, 0x0432, 0x0443,
+ 0x0439, 0x0442, 0x0435, '!', ' ',
+ 'x', '=', '(', '-', 'b', 0x00B1, 's', 'q', 'r', 't', '(', 'b', 0x00B2,
+ '-', '4', 'a', 'c', ')', ')', '/', '(', '2', 'a', ')', ' ', ' ',
+ 0x65E5, 0x672C, 0x8A9E, ',', 0x4E2D, 0x6587, ',', 0xD55C, 0xAE00, '\n'
};
static const uint32_t expected[] =
{ 'G', 'r', 0x0075, 0x0308, 0x00DF, ' ', 'G', 'o', 't', 't', '.', ' ',
- 0x0417, 0x0434, 0x0440, 0x0430, 0x0432, 0x0441, 0x0442, 0x0432, 0x0443,
- 0x0438, 0x0306, 0x0442, 0x0435, '!', ' ',
- 'x', '=', '(', '-', 'b', 0x00B1, 's', 'q', 'r', 't', '(', 'b', 0x0032,
- '-', '4', 'a', 'c', ')', ')', '/', '(', '2', 'a', ')', ' ', ' ',
- 0x65E5, 0x672C, 0x8A9E, ',', 0x4E2D, 0x6587, ',',
- 0x1112, 0x1161, 0x11AB, 0x1100, 0x1173, 0x11AF, '\n'
+ 0x0417, 0x0434, 0x0440, 0x0430, 0x0432, 0x0441, 0x0442, 0x0432, 0x0443,
+ 0x0438, 0x0306, 0x0442, 0x0435, '!', ' ',
+ 'x', '=', '(', '-', 'b', 0x00B1, 's', 'q', 'r', 't', '(', 'b', 0x0032,
+ '-', '4', 'a', 'c', ')', ')', '/', '(', '2', 'a', ')', ' ', ' ',
+ 0x65E5, 0x672C, 0x8A9E, ',', 0x4E2D, 0x6587, ',',
+ 0x1112, 0x1161, 0x11AB, 0x1100, 0x1173, 0x11AF, '\n'
};
ASSERT (check (input, SIZEOF (input), expected, SIZEOF (expected)) == 0);
}
@@ -279,62 +266,62 @@ test_u32_nfkd (void)
int pass;
for (pass = 0; pass < 3; pass++)
{
- size_t repeat = 1;
- size_t m = 100000;
- uint32_t *input = (uint32_t *) malloc (2 * m * sizeof (uint32_t));
- if (input != NULL)
- {
- uint32_t *expected = input + m;
- size_t m1 = m / 2;
- size_t m2 = (m - 1) / 2;
- /* NB: m1 + m2 == m - 1. */
- uint32_t *p;
- size_t i;
-
- input[0] = 0x0041;
- p = input + 1;
- switch (pass)
- {
- case 0:
- for (i = 0; i < m1; i++)
- *p++ = 0x0319;
- for (i = 0; i < m2; i++)
- *p++ = 0x0300;
- break;
-
- case 1:
- for (i = 0; i < m2; i++)
- *p++ = 0x0300;
- for (i = 0; i < m1; i++)
- *p++ = 0x0319;
- break;
-
- case 2:
- for (i = 0; i < m2; i++)
- {
- *p++ = 0x0319;
- *p++ = 0x0300;
- }
- for (; i < m1; i++)
- *p++ = 0x0319;
- break;
-
- default:
- abort ();
- }
-
- expected[0] = 0x0041;
- p = expected + 1;
- for (i = 0; i < m1; i++)
- *p++ = 0x0319;
- for (i = 0; i < m2; i++)
- *p++ = 0x0300;
-
- for (; repeat > 0; repeat--)
- ASSERT (check (input, m, expected, m) == 0);
-
- free (input);
- }
+ size_t repeat = 1;
+ size_t m = 100000;
+ uint32_t *input = (uint32_t *) malloc (2 * m * sizeof (uint32_t));
+ if (input != NULL)
+ {
+ uint32_t *expected = input + m;
+ size_t m1 = m / 2;
+ size_t m2 = (m - 1) / 2;
+ /* NB: m1 + m2 == m - 1. */
+ uint32_t *p;
+ size_t i;
+
+ input[0] = 0x0041;
+ p = input + 1;
+ switch (pass)
+ {
+ case 0:
+ for (i = 0; i < m1; i++)
+ *p++ = 0x0319;
+ for (i = 0; i < m2; i++)
+ *p++ = 0x0300;
+ break;
+
+ case 1:
+ for (i = 0; i < m2; i++)
+ *p++ = 0x0300;
+ for (i = 0; i < m1; i++)
+ *p++ = 0x0319;
+ break;
+
+ case 2:
+ for (i = 0; i < m2; i++)
+ {
+ *p++ = 0x0319;
+ *p++ = 0x0300;
+ }
+ for (; i < m1; i++)
+ *p++ = 0x0319;
+ break;
+
+ default:
+ abort ();
+ }
+
+ expected[0] = 0x0041;
+ p = expected + 1;
+ for (i = 0; i < m1; i++)
+ *p++ = 0x0319;
+ for (i = 0; i < m2; i++)
+ *p++ = 0x0300;
+
+ for (; repeat > 0; repeat--)
+ ASSERT (check (input, m, expected, m) == 0);
+
+ free (input);
+ }
}
}
}
diff --git a/tests/uninorm/test-u32-normalize-big.c b/tests/uninorm/test-u32-normalize-big.c
index 96781ab0..6c637862 100644
--- a/tests/uninorm/test-u32-normalize-big.c
+++ b/tests/uninorm/test-u32-normalize-big.c
@@ -1,5 +1,5 @@
/* Test of Unicode compliance of normalization of UTF-32 strings.
- Copyright (C) 2009 Free Software Foundation, Inc.
+ Copyright (C) 2009, 2010 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -21,37 +21,26 @@
/* Specification. */
#include "test-u32-normalize-big.h"
-#if GNULIB_UNINORM_U32_NORMALIZE
+#if GNULIB_TEST_UNINORM_U32_NORMALIZE
#include <stdio.h>
#include <stdlib.h>
#include "xalloc.h"
#include "unistr.h"
-
-#define ASSERT(expr) \
- do \
- { \
- if (!(expr)) \
- { \
- fprintf (stderr, "%s:%d: assertion failed\n", __FILE__, __LINE__); \
- fflush (stderr); \
- abort (); \
- } \
- } \
- while (0)
+#include "macros.h"
#define ASSERT_WITH_LINE(expr, file, line) \
- do \
- { \
- if (!(expr)) \
- { \
- fprintf (stderr, "%s:%d: assertion failed for %s:%u\n", \
- __FILE__, __LINE__, file, line); \
- fflush (stderr); \
- abort (); \
- } \
- } \
+ do \
+ { \
+ if (!(expr)) \
+ { \
+ fprintf (stderr, "%s:%d: assertion failed for %s:%u\n", \
+ __FILE__, __LINE__, file, line); \
+ fflush (stderr); \
+ abort (); \
+ } \
+ } \
while (0)
static int
@@ -64,7 +53,7 @@ cmp_ucs4_t (const void *a, const void *b)
void
read_normalization_test_file (const char *filename,
- struct normalization_test_file *file)
+ struct normalization_test_file *file)
{
FILE *stream;
unsigned int lineno;
@@ -106,103 +95,103 @@ read_normalization_test_file (const char *filename,
/* Read a line. */
ptr = buf;
do
- {
- c = getc (stream);
- if (c == EOF || c == '\n')
- break;
- *ptr++ = c;
- }
+ {
+ c = getc (stream);
+ if (c == EOF || c == '\n')
+ break;
+ *ptr++ = c;
+ }
while (ptr < buf + 1000);
*ptr = '\0';
if (c == EOF)
- break;
+ break;
/* Ignore empty lines and comment lines. */
if (buf[0] == '\0' || buf[0] == '#')
- continue;
+ continue;
/* Handle lines that introduce a new part. */
if (buf[0] == '@')
- {
- /* Switch to the next part. */
- if (part_index >= 0)
- {
- lines =
- (struct normalization_test_line *)
- xnrealloc (lines, lines_length, sizeof (struct normalization_test_line));
- file->parts[part_index].lines = lines;
- file->parts[part_index].lines_length = lines_length;
- }
- part_index++;
- lines = NULL;
- lines_length = 0;
- lines_allocated = 0;
- continue;
- }
+ {
+ /* Switch to the next part. */
+ if (part_index >= 0)
+ {
+ lines =
+ (struct normalization_test_line *)
+ xnrealloc (lines, lines_length, sizeof (struct normalization_test_line));
+ file->parts[part_index].lines = lines;
+ file->parts[part_index].lines_length = lines_length;
+ }
+ part_index++;
+ lines = NULL;
+ lines_length = 0;
+ lines_allocated = 0;
+ continue;
+ }
/* It's a line containing 5 sequences of Unicode characters.
- Parse it and append it to the current part. */
+ Parse it and append it to the current part. */
if (!(part_index >= 0 && part_index < 4))
- {
- fprintf (stderr, "unexpected structure of '%s'\n", filename);
- exit (1);
- }
+ {
+ fprintf (stderr, "unexpected structure of '%s'\n", filename);
+ exit (1);
+ }
ptr = buf;
line.lineno = lineno;
for (sequence_index = 0; sequence_index < 5; sequence_index++)
- line.sequences[sequence_index] = NULL;
+ line.sequences[sequence_index] = NULL;
for (sequence_index = 0; sequence_index < 5; sequence_index++)
- {
- uint32_t *sequence = XNMALLOC (1, uint32_t);
- size_t sequence_length = 0;
-
- for (;;)
- {
- char *endptr;
- unsigned int uc;
-
- uc = strtoul (ptr, &endptr, 16);
- if (endptr == ptr)
- break;
- ptr = endptr;
-
- /* Append uc to the sequence. */
- sequence =
- (uint32_t *)
- xnrealloc (sequence, sequence_length + 2, sizeof (uint32_t));
- sequence[sequence_length] = uc;
- sequence_length++;
-
- if (*ptr == ' ')
- ptr++;
- }
- if (sequence_length == 0)
- {
- fprintf (stderr, "empty character sequence in '%s'\n", filename);
- exit (1);
- }
- sequence[sequence_length] = 0; /* terminator */
-
- line.sequences[sequence_index] = sequence;
-
- if (*ptr != ';')
- {
- fprintf (stderr, "error parsing '%s'\n", filename);
- exit (1);
- }
- ptr++;
- }
+ {
+ uint32_t *sequence = XNMALLOC (1, uint32_t);
+ size_t sequence_length = 0;
+
+ for (;;)
+ {
+ char *endptr;
+ unsigned int uc;
+
+ uc = strtoul (ptr, &endptr, 16);
+ if (endptr == ptr)
+ break;
+ ptr = endptr;
+
+ /* Append uc to the sequence. */
+ sequence =
+ (uint32_t *)
+ xnrealloc (sequence, sequence_length + 2, sizeof (uint32_t));
+ sequence[sequence_length] = uc;
+ sequence_length++;
+
+ if (*ptr == ' ')
+ ptr++;
+ }
+ if (sequence_length == 0)
+ {
+ fprintf (stderr, "empty character sequence in '%s'\n", filename);
+ exit (1);
+ }
+ sequence[sequence_length] = 0; /* terminator */
+
+ line.sequences[sequence_index] = sequence;
+
+ if (*ptr != ';')
+ {
+ fprintf (stderr, "error parsing '%s'\n", filename);
+ exit (1);
+ }
+ ptr++;
+ }
/* Append the line to the current part. */
if (lines_length == lines_allocated)
- {
- lines_allocated = 2 * lines_allocated;
- if (lines_allocated < 7)
- lines_allocated = 7;
- lines =
- (struct normalization_test_line *)
- xnrealloc (lines, lines_allocated, sizeof (struct normalization_test_line));
- }
+ {
+ lines_allocated = 2 * lines_allocated;
+ if (lines_allocated < 7)
+ lines_allocated = 7;
+ lines =
+ (struct normalization_test_line *)
+ xnrealloc (lines, lines_allocated, sizeof (struct normalization_test_line));
+ }
lines[lines_length] = line;
lines_length++;
}
@@ -210,8 +199,8 @@ read_normalization_test_file (const char *filename,
if (part_index >= 0)
{
lines =
- (struct normalization_test_line *)
- xnrealloc (lines, lines_length, sizeof (struct normalization_test_line));
+ (struct normalization_test_line *)
+ xnrealloc (lines, lines_length, sizeof (struct normalization_test_line));
file->parts[part_index].lines = lines;
file->parts[part_index].lines_length = lines_length;
}
@@ -224,11 +213,11 @@ read_normalization_test_file (const char *filename,
for (line_index = 0; line_index < p->lines_length; line_index++)
{
- const uint32_t *sequence = p->lines[line_index].sequences[0];
- /* In part 1, every sequences[0] consists of a single character. */
- if (!(sequence[0] != 0 && sequence[1] == 0))
- abort ();
- c1_array[line_index] = sequence[0];
+ const uint32_t *sequence = p->lines[line_index].sequences[0];
+ /* In part 1, every sequences[0] consists of a single character. */
+ if (!(sequence[0] != 0 && sequence[1] == 0))
+ abort ();
+ c1_array[line_index] = sequence[0];
}
/* Sort this array. */
@@ -251,11 +240,11 @@ read_normalization_test_file (const char *filename,
void
test_specific (const struct normalization_test_file *file,
- int (*check) (const uint32_t *c1, size_t c1_length,
- const uint32_t *c2, size_t c2_length,
- const uint32_t *c3, size_t c3_length,
- const uint32_t *c4, size_t c4_length,
- const uint32_t *c5, size_t c5_length))
+ int (*check) (const uint32_t *c1, size_t c1_length,
+ const uint32_t *c2, size_t c2_length,
+ const uint32_t *c3, size_t c3_length,
+ const uint32_t *c4, size_t c4_length,
+ const uint32_t *c5, size_t c5_length))
{
size_t part_index;
@@ -265,17 +254,17 @@ test_specific (const struct normalization_test_file *file,
size_t line_index;
for (line_index = 0; line_index < p->lines_length; line_index++)
- {
- const struct normalization_test_line *l = &p->lines[line_index];
-
- ASSERT_WITH_LINE (check (l->sequences[0], u32_strlen (l->sequences[0]),
- l->sequences[1], u32_strlen (l->sequences[1]),
- l->sequences[2], u32_strlen (l->sequences[2]),
- l->sequences[3], u32_strlen (l->sequences[3]),
- l->sequences[4], u32_strlen (l->sequences[4]))
- == 0,
- file->filename, l->lineno);
- }
+ {
+ const struct normalization_test_line *l = &p->lines[line_index];
+
+ ASSERT_WITH_LINE (check (l->sequences[0], u32_strlen (l->sequences[0]),
+ l->sequences[1], u32_strlen (l->sequences[1]),
+ l->sequences[2], u32_strlen (l->sequences[2]),
+ l->sequences[3], u32_strlen (l->sequences[3]),
+ l->sequences[4], u32_strlen (l->sequences[4]))
+ == 0,
+ file->filename, l->lineno);
+ }
}
}
@@ -291,24 +280,24 @@ test_other (const struct normalization_test_file *file, uninorm_t nf)
for (uc = 0; uc < 0x110000; uc++)
{
if (uc >= 0xD800 && uc < 0xE000)
- {
- /* A surrogate, not a character. Skip uc. */
- }
+ {
+ /* A surrogate, not a character. Skip uc. */
+ }
else if (uc == *p)
- {
- /* Skip uc. */
- p++;
- }
+ {
+ /* Skip uc. */
+ p++;
+ }
else
- {
- uint32_t input[1];
- size_t length;
- uint32_t *result;
-
- input[0] = uc;
- result = u32_normalize (nf, input, 1, NULL, &length);
- ASSERT (result != NULL && length == 1 && result[0] == uc);
- }
+ {
+ uint32_t input[1];
+ size_t length;
+ uint32_t *result;
+
+ input[0] = uc;
+ result = u32_normalize (nf, input, 1, NULL, &length);
+ ASSERT (result != NULL && length == 1 && result[0] == uc);
+ }
}
}
diff --git a/tests/uninorm/test-u32-normalize-big.h b/tests/uninorm/test-u32-normalize-big.h
index f154daa9..2482a34a 100644
--- a/tests/uninorm/test-u32-normalize-big.h
+++ b/tests/uninorm/test-u32-normalize-big.h
@@ -1,5 +1,5 @@
/* Test of Unicode compliance of normalization of UTF-32 strings.
- Copyright (C) 2009 Free Software Foundation, Inc.
+ Copyright (C) 2009, 2010 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -54,16 +54,16 @@ struct normalization_test_file
/* Read the NormalizationTest.txt file and return its contents. */
extern void
read_normalization_test_file (const char *filename,
- struct normalization_test_file *file);
+ struct normalization_test_file *file);
/* Perform the first compliance test. */
extern void
test_specific (const struct normalization_test_file *file,
- int (*check) (const uint32_t *c1, size_t c1_length,
- const uint32_t *c2, size_t c2_length,
- const uint32_t *c3, size_t c3_length,
- const uint32_t *c4, size_t c4_length,
- const uint32_t *c5, size_t c5_length));
+ int (*check) (const uint32_t *c1, size_t c1_length,
+ const uint32_t *c2, size_t c2_length,
+ const uint32_t *c3, size_t c3_length,
+ const uint32_t *c4, size_t c4_length,
+ const uint32_t *c5, size_t c5_length));
/* Perform the second compliance test. */
extern void
diff --git a/tests/uninorm/test-u32-normcmp.c b/tests/uninorm/test-u32-normcmp.c
index 846300a8..e48ceeba 100644
--- a/tests/uninorm/test-u32-normcmp.c
+++ b/tests/uninorm/test-u32-normcmp.c
@@ -1,5 +1,5 @@
/* Test of normalization insensitive comparison of UTF-32 strings.
- Copyright (C) 2009 Free Software Foundation, Inc.
+ Copyright (C) 2009, 2010 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -20,21 +20,7 @@
#include "uninorm.h"
-#include <stdio.h>
-#include <stdlib.h>
-
-#define SIZEOF(array) (sizeof (array) / sizeof (array[0]))
-#define ASSERT(expr) \
- do \
- { \
- if (!(expr)) \
- { \
- fprintf (stderr, "%s:%d: assertion failed\n", __FILE__, __LINE__); \
- fflush (stderr); \
- abort (); \
- } \
- } \
- while (0)
+#include "macros.h"
#include "test-u32-normcmp.h"
diff --git a/tests/uninorm/test-u32-normcmp.h b/tests/uninorm/test-u32-normcmp.h
index 06d5fad8..56d4cdba 100644
--- a/tests/uninorm/test-u32-normcmp.h
+++ b/tests/uninorm/test-u32-normcmp.h
@@ -1,5 +1,5 @@
/* Test of normalization insensitive comparison of UTF-32 strings.
- Copyright (C) 2009 Free Software Foundation, Inc.
+ Copyright (C) 2009, 2010 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -18,7 +18,7 @@
static void
test_ascii (int (*my_normcmp) (const uint32_t *, size_t, const uint32_t *, size_t, uninorm_t, int *),
- uninorm_t nf)
+ uninorm_t nf)
{
/* Empty string. */
{
diff --git a/tests/uninorm/test-u32-normcoll.c b/tests/uninorm/test-u32-normcoll.c
index 916d433f..08777ee3 100644
--- a/tests/uninorm/test-u32-normcoll.c
+++ b/tests/uninorm/test-u32-normcoll.c
@@ -1,6 +1,6 @@
/* Test of locale dependent, normalization insensitive comparison of
UTF-32 strings.
- Copyright (C) 2009 Free Software Foundation, Inc.
+ Copyright (C) 2009, 2010 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -21,21 +21,7 @@
#include "uninorm.h"
-#include <stdio.h>
-#include <stdlib.h>
-
-#define SIZEOF(array) (sizeof (array) / sizeof (array[0]))
-#define ASSERT(expr) \
- do \
- { \
- if (!(expr)) \
- { \
- fprintf (stderr, "%s:%d: assertion failed\n", __FILE__, __LINE__); \
- fflush (stderr); \
- abort (); \
- } \
- } \
- while (0)
+#include "macros.h"
#include "test-u32-normcmp.h"
int
diff --git a/tests/uninorm/test-u8-nfc.c b/tests/uninorm/test-u8-nfc.c
index 52baa68b..1a7745cf 100644
--- a/tests/uninorm/test-u8-nfc.c
+++ b/tests/uninorm/test-u8-nfc.c
@@ -1,5 +1,5 @@
/* Test of canonical normalization of UTF-8 strings.
- Copyright (C) 2009 Free Software Foundation, Inc.
+ Copyright (C) 2009, 2010 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -18,29 +18,16 @@
#include <config.h>
-#if GNULIB_UNINORM_U8_NORMALIZE
+#if GNULIB_TEST_UNINORM_U8_NORMALIZE
#include "uninorm.h"
#include <signal.h>
-#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include "unistr.h"
-
-#define SIZEOF(array) (sizeof (array) / sizeof (array[0]))
-#define ASSERT(expr) \
- do \
- { \
- if (!(expr)) \
- { \
- fprintf (stderr, "%s:%d: assertion failed\n", __FILE__, __LINE__); \
- fflush (stderr); \
- abort (); \
- } \
- } \
- while (0)
+#include "macros.h"
static int
check (const uint8_t *input, size_t input_length,
@@ -68,13 +55,13 @@ check (const uint8_t *input, size_t input_length,
preallocated = (uint8_t *) malloc (length * sizeof (uint8_t));
result = u8_normalize (UNINORM_NFC, input, input_length, preallocated, &length);
if (!(result != NULL))
- return 4;
+ return 4;
if (!(result != preallocated))
- return 5;
+ return 5;
if (!(length == expected_length))
- return 6;
+ return 6;
if (!(u8_cmp (result, expected, expected_length) == 0))
- return 7;
+ return 7;
free (result);
free (preallocated);
}
@@ -242,25 +229,25 @@ test_u8_nfc (void)
{ /* "Grüß Gott. Здравствуйте! x=(-b±sqrt(b²-4ac))/(2a) 日本語,中文,한글" */
static const uint8_t input[] =
{ 'G', 'r', 0xC3, 0xBC, 0xC3, 0x9F, ' ', 'G', 'o', 't', 't', '.',
- ' ', 0xD0, 0x97, 0xD0, 0xB4, 0xD1, 0x80, 0xD0, 0xB0, 0xD0, 0xB2, 0xD1,
- 0x81, 0xD1, 0x82, 0xD0, 0xB2, 0xD1, 0x83, 0xD0, 0xB9,
- 0xD1, 0x82, 0xD0, 0xB5, '!', ' ', 'x', '=', '(', '-', 'b', 0xC2, 0xB1,
- 's', 'q', 'r', 't', '(', 'b', 0xC2, 0xB2, '-', '4', 'a', 'c', ')', ')',
- '/', '(', '2', 'a', ')', ' ', ' ', 0xE6, 0x97, 0xA5, 0xE6, 0x9C, 0xAC,
- 0xE8, 0xAA, 0x9E, ',', 0xE4, 0xB8, 0xAD, 0xE6, 0x96, 0x87, ',',
- 0xED, 0x95, 0x9C,
- 0xEA, 0xB8, 0x80, '\n'
+ ' ', 0xD0, 0x97, 0xD0, 0xB4, 0xD1, 0x80, 0xD0, 0xB0, 0xD0, 0xB2, 0xD1,
+ 0x81, 0xD1, 0x82, 0xD0, 0xB2, 0xD1, 0x83, 0xD0, 0xB9,
+ 0xD1, 0x82, 0xD0, 0xB5, '!', ' ', 'x', '=', '(', '-', 'b', 0xC2, 0xB1,
+ 's', 'q', 'r', 't', '(', 'b', 0xC2, 0xB2, '-', '4', 'a', 'c', ')', ')',
+ '/', '(', '2', 'a', ')', ' ', ' ', 0xE6, 0x97, 0xA5, 0xE6, 0x9C, 0xAC,
+ 0xE8, 0xAA, 0x9E, ',', 0xE4, 0xB8, 0xAD, 0xE6, 0x96, 0x87, ',',
+ 0xED, 0x95, 0x9C,
+ 0xEA, 0xB8, 0x80, '\n'
};
static const uint8_t decomposed[] =
{ 'G', 'r', 0x75, 0xCC, 0x88, 0xC3, 0x9F, ' ', 'G', 'o', 't', 't', '.',
- ' ', 0xD0, 0x97, 0xD0, 0xB4, 0xD1, 0x80, 0xD0, 0xB0, 0xD0, 0xB2, 0xD1,
- 0x81, 0xD1, 0x82, 0xD0, 0xB2, 0xD1, 0x83, 0xD0, 0xB8, 0xCC, 0x86,
- 0xD1, 0x82, 0xD0, 0xB5, '!', ' ', 'x', '=', '(', '-', 'b', 0xC2, 0xB1,
- 's', 'q', 'r', 't', '(', 'b', 0xC2, 0xB2, '-', '4', 'a', 'c', ')', ')',
- '/', '(', '2', 'a', ')', ' ', ' ', 0xE6, 0x97, 0xA5, 0xE6, 0x9C, 0xAC,
- 0xE8, 0xAA, 0x9E, ',', 0xE4, 0xB8, 0xAD, 0xE6, 0x96, 0x87, ',',
- 0xE1, 0x84, 0x92, 0xE1, 0x85, 0xA1, 0xE1, 0x86, 0xAB,
- 0xE1, 0x84, 0x80, 0xE1, 0x85, 0xB3, 0xE1, 0x86, 0xAF, '\n'
+ ' ', 0xD0, 0x97, 0xD0, 0xB4, 0xD1, 0x80, 0xD0, 0xB0, 0xD0, 0xB2, 0xD1,
+ 0x81, 0xD1, 0x82, 0xD0, 0xB2, 0xD1, 0x83, 0xD0, 0xB8, 0xCC, 0x86,
+ 0xD1, 0x82, 0xD0, 0xB5, '!', ' ', 'x', '=', '(', '-', 'b', 0xC2, 0xB1,
+ 's', 'q', 'r', 't', '(', 'b', 0xC2, 0xB2, '-', '4', 'a', 'c', ')', ')',
+ '/', '(', '2', 'a', ')', ' ', ' ', 0xE6, 0x97, 0xA5, 0xE6, 0x9C, 0xAC,
+ 0xE8, 0xAA, 0x9E, ',', 0xE4, 0xB8, 0xAD, 0xE6, 0x96, 0x87, ',',
+ 0xE1, 0x84, 0x92, 0xE1, 0x85, 0xA1, 0xE1, 0x86, 0xAB,
+ 0xE1, 0x84, 0x80, 0xE1, 0x85, 0xB3, 0xE1, 0x86, 0xAF, '\n'
};
ASSERT (check (input, SIZEOF (input), input, SIZEOF (input)) == 0);
ASSERT (check (decomposed, SIZEOF (decomposed), input, SIZEOF (input)) == 0);
@@ -278,89 +265,89 @@ test_u8_nfc (void)
int pass;
for (pass = 0; pass < 3; pass++)
{
- size_t repeat = 1;
- size_t m = 100000;
- uint8_t *input = (uint8_t *) malloc (2 * (2 * m - 1) * sizeof (uint8_t));
- if (input != NULL)
- {
- uint8_t *expected = input + (2 * m - 1);
- size_t m1 = m / 2;
- size_t m2 = (m - 1) / 2;
- /* NB: m1 + m2 == m - 1. */
- uint8_t *p;
- size_t i;
-
- input[0] = 0x41;
- p = input + 1;
- switch (pass)
- {
- case 0:
- for (i = 0; i < m1; i++)
- {
- *p++ = 0xCC;
- *p++ = 0x99;
- }
- for (i = 0; i < m2; i++)
- {
- *p++ = 0xCC;
- *p++ = 0x80;
- }
- break;
-
- case 1:
- for (i = 0; i < m2; i++)
- {
- *p++ = 0xCC;
- *p++ = 0x80;
- }
- for (i = 0; i < m1; i++)
- {
- *p++ = 0xCC;
- *p++ = 0x99;
- }
- break;
-
- case 2:
- for (i = 0; i < m2; i++)
- {
- *p++ = 0xCC;
- *p++ = 0x99;
- *p++ = 0xCC;
- *p++ = 0x80;
- }
- for (; i < m1; i++)
- {
- *p++ = 0xCC;
- *p++ = 0x99;
- }
- break;
-
- default:
- abort ();
- }
-
- expected[0] = 0xC3;
- expected[1] = 0x80;
- p = expected + 2;
- for (i = 0; i < m1; i++)
- {
- *p++ = 0xCC;
- *p++ = 0x99;
- }
- for (i = 0; i < m2 - 1; i++)
- {
- *p++ = 0xCC;
- *p++ = 0x80;
- }
-
- for (; repeat > 0; repeat--)
- {
- ASSERT (check (input, 2 * m - 1, expected, 2 * m - 2) == 0);
- ASSERT (check (expected, 2 * m - 2, expected, 2 * m - 2) == 0);
- }
-
- free (input);
- }
+ size_t repeat = 1;
+ size_t m = 100000;
+ uint8_t *input = (uint8_t *) malloc (2 * (2 * m - 1) * sizeof (uint8_t));
+ if (input != NULL)
+ {
+ uint8_t *expected = input + (2 * m - 1);
+ size_t m1 = m / 2;
+ size_t m2 = (m - 1) / 2;
+ /* NB: m1 + m2 == m - 1. */
+ uint8_t *p;
+ size_t i;
+
+ input[0] = 0x41;
+ p = input + 1;
+ switch (pass)
+ {
+ case 0:
+ for (i = 0; i < m1; i++)
+ {
+ *p++ = 0xCC;
+ *p++ = 0x99;
+ }
+ for (i = 0; i < m2; i++)
+ {
+ *p++ = 0xCC;
+ *p++ = 0x80;
+ }
+ break;
+
+ case 1:
+ for (i = 0; i < m2; i++)
+ {
+ *p++ = 0xCC;
+ *p++ = 0x80;
+ }
+ for (i = 0; i < m1; i++)
+ {
+ *p++ = 0xCC;
+ *p++ = 0x99;
+ }
+ break;
+
+ case 2:
+ for (i = 0; i < m2; i++)
+ {
+ *p++ = 0xCC;
+ *p++ = 0x99;
+ *p++ = 0xCC;
+ *p++ = 0x80;
+ }
+ for (; i < m1; i++)
+ {
+ *p++ = 0xCC;
+ *p++ = 0x99;
+ }
+ break;
+
+ default:
+ abort ();
+ }
+
+ expected[0] = 0xC3;
+ expected[1] = 0x80;
+ p = expected + 2;
+ for (i = 0; i < m1; i++)
+ {
+ *p++ = 0xCC;
+ *p++ = 0x99;
+ }
+ for (i = 0; i < m2 - 1; i++)
+ {
+ *p++ = 0xCC;
+ *p++ = 0x80;
+ }
+
+ for (; repeat > 0; repeat--)
+ {
+ ASSERT (check (input, 2 * m - 1, expected, 2 * m - 2) == 0);
+ ASSERT (check (expected, 2 * m - 2, expected, 2 * m - 2) == 0);
+ }
+
+ free (input);
+ }
}
}
}
diff --git a/tests/uninorm/test-u8-nfd.c b/tests/uninorm/test-u8-nfd.c
index d1d840ac..082ded4a 100644
--- a/tests/uninorm/test-u8-nfd.c
+++ b/tests/uninorm/test-u8-nfd.c
@@ -1,5 +1,5 @@
/* Test of canonical decomposition of UTF-8 strings.
- Copyright (C) 2009 Free Software Foundation, Inc.
+ Copyright (C) 2009, 2010 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -18,29 +18,16 @@
#include <config.h>
-#if GNULIB_UNINORM_U8_NORMALIZE
+#if GNULIB_TEST_UNINORM_U8_NORMALIZE
#include "uninorm.h"
#include <signal.h>
-#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include "unistr.h"
-
-#define SIZEOF(array) (sizeof (array) / sizeof (array[0]))
-#define ASSERT(expr) \
- do \
- { \
- if (!(expr)) \
- { \
- fprintf (stderr, "%s:%d: assertion failed\n", __FILE__, __LINE__); \
- fflush (stderr); \
- abort (); \
- } \
- } \
- while (0)
+#include "macros.h"
static int
check (const uint8_t *input, size_t input_length,
@@ -68,13 +55,13 @@ check (const uint8_t *input, size_t input_length,
preallocated = (uint8_t *) malloc (length * sizeof (uint8_t));
result = u8_normalize (UNINORM_NFD, input, input_length, preallocated, &length);
if (!(result != NULL))
- return 4;
+ return 4;
if (!(result != preallocated))
- return 5;
+ return 5;
if (!(length == expected_length))
- return 6;
+ return 6;
if (!(u8_cmp (result, expected, expected_length) == 0))
- return 7;
+ return 7;
free (result);
free (preallocated);
}
@@ -230,25 +217,25 @@ test_u8_nfd (void)
{ /* "Grüß Gott. Здравствуйте! x=(-b±sqrt(b²-4ac))/(2a) 日本語,中文,한글" */
static const uint8_t input[] =
{ 'G', 'r', 0xC3, 0xBC, 0xC3, 0x9F, ' ', 'G', 'o', 't', 't', '.',
- ' ', 0xD0, 0x97, 0xD0, 0xB4, 0xD1, 0x80, 0xD0, 0xB0, 0xD0, 0xB2, 0xD1,
- 0x81, 0xD1, 0x82, 0xD0, 0xB2, 0xD1, 0x83, 0xD0, 0xB9,
- 0xD1, 0x82, 0xD0, 0xB5, '!', ' ', 'x', '=', '(', '-', 'b', 0xC2, 0xB1,
- 's', 'q', 'r', 't', '(', 'b', 0xC2, 0xB2, '-', '4', 'a', 'c', ')', ')',
- '/', '(', '2', 'a', ')', ' ', ' ', 0xE6, 0x97, 0xA5, 0xE6, 0x9C, 0xAC,
- 0xE8, 0xAA, 0x9E, ',', 0xE4, 0xB8, 0xAD, 0xE6, 0x96, 0x87, ',',
- 0xED, 0x95, 0x9C,
- 0xEA, 0xB8, 0x80, '\n'
+ ' ', 0xD0, 0x97, 0xD0, 0xB4, 0xD1, 0x80, 0xD0, 0xB0, 0xD0, 0xB2, 0xD1,
+ 0x81, 0xD1, 0x82, 0xD0, 0xB2, 0xD1, 0x83, 0xD0, 0xB9,
+ 0xD1, 0x82, 0xD0, 0xB5, '!', ' ', 'x', '=', '(', '-', 'b', 0xC2, 0xB1,
+ 's', 'q', 'r', 't', '(', 'b', 0xC2, 0xB2, '-', '4', 'a', 'c', ')', ')',
+ '/', '(', '2', 'a', ')', ' ', ' ', 0xE6, 0x97, 0xA5, 0xE6, 0x9C, 0xAC,
+ 0xE8, 0xAA, 0x9E, ',', 0xE4, 0xB8, 0xAD, 0xE6, 0x96, 0x87, ',',
+ 0xED, 0x95, 0x9C,
+ 0xEA, 0xB8, 0x80, '\n'
};
static const uint8_t expected[] =
{ 'G', 'r', 0x75, 0xCC, 0x88, 0xC3, 0x9F, ' ', 'G', 'o', 't', 't', '.',
- ' ', 0xD0, 0x97, 0xD0, 0xB4, 0xD1, 0x80, 0xD0, 0xB0, 0xD0, 0xB2, 0xD1,
- 0x81, 0xD1, 0x82, 0xD0, 0xB2, 0xD1, 0x83, 0xD0, 0xB8, 0xCC, 0x86,
- 0xD1, 0x82, 0xD0, 0xB5, '!', ' ', 'x', '=', '(', '-', 'b', 0xC2, 0xB1,
- 's', 'q', 'r', 't', '(', 'b', 0xC2, 0xB2, '-', '4', 'a', 'c', ')', ')',
- '/', '(', '2', 'a', ')', ' ', ' ', 0xE6, 0x97, 0xA5, 0xE6, 0x9C, 0xAC,
- 0xE8, 0xAA, 0x9E, ',', 0xE4, 0xB8, 0xAD, 0xE6, 0x96, 0x87, ',',
- 0xE1, 0x84, 0x92, 0xE1, 0x85, 0xA1, 0xE1, 0x86, 0xAB,
- 0xE1, 0x84, 0x80, 0xE1, 0x85, 0xB3, 0xE1, 0x86, 0xAF, '\n'
+ ' ', 0xD0, 0x97, 0xD0, 0xB4, 0xD1, 0x80, 0xD0, 0xB0, 0xD0, 0xB2, 0xD1,
+ 0x81, 0xD1, 0x82, 0xD0, 0xB2, 0xD1, 0x83, 0xD0, 0xB8, 0xCC, 0x86,
+ 0xD1, 0x82, 0xD0, 0xB5, '!', ' ', 'x', '=', '(', '-', 'b', 0xC2, 0xB1,
+ 's', 'q', 'r', 't', '(', 'b', 0xC2, 0xB2, '-', '4', 'a', 'c', ')', ')',
+ '/', '(', '2', 'a', ')', ' ', ' ', 0xE6, 0x97, 0xA5, 0xE6, 0x9C, 0xAC,
+ 0xE8, 0xAA, 0x9E, ',', 0xE4, 0xB8, 0xAD, 0xE6, 0x96, 0x87, ',',
+ 0xE1, 0x84, 0x92, 0xE1, 0x85, 0xA1, 0xE1, 0x86, 0xAB,
+ 0xE1, 0x84, 0x80, 0xE1, 0x85, 0xB3, 0xE1, 0x86, 0xAF, '\n'
};
ASSERT (check (input, SIZEOF (input), expected, SIZEOF (expected)) == 0);
}
@@ -265,85 +252,85 @@ test_u8_nfd (void)
int pass;
for (pass = 0; pass < 3; pass++)
{
- size_t repeat = 1;
- size_t m = 100000;
- uint8_t *input = (uint8_t *) malloc (2 * (2 * m - 1) * sizeof (uint8_t));
- if (input != NULL)
- {
- uint8_t *expected = input + (2 * m - 1);
- size_t m1 = m / 2;
- size_t m2 = (m - 1) / 2;
- /* NB: m1 + m2 == m - 1. */
- uint8_t *p;
- size_t i;
-
- input[0] = 0x41;
- p = input + 1;
- switch (pass)
- {
- case 0:
- for (i = 0; i < m1; i++)
- {
- *p++ = 0xCC;
- *p++ = 0x99;
- }
- for (i = 0; i < m2; i++)
- {
- *p++ = 0xCC;
- *p++ = 0x80;
- }
- break;
-
- case 1:
- for (i = 0; i < m2; i++)
- {
- *p++ = 0xCC;
- *p++ = 0x80;
- }
- for (i = 0; i < m1; i++)
- {
- *p++ = 0xCC;
- *p++ = 0x99;
- }
- break;
-
- case 2:
- for (i = 0; i < m2; i++)
- {
- *p++ = 0xCC;
- *p++ = 0x99;
- *p++ = 0xCC;
- *p++ = 0x80;
- }
- for (; i < m1; i++)
- {
- *p++ = 0xCC;
- *p++ = 0x99;
- }
- break;
-
- default:
- abort ();
- }
-
- expected[0] = 0x41;
- p = expected + 1;
- for (i = 0; i < m1; i++)
- {
- *p++ = 0xCC;
- *p++ = 0x99;
- }
- for (i = 0; i < m2; i++)
- {
- *p++ = 0xCC;
- *p++ = 0x80;
- }
-
- for (; repeat > 0; repeat--)
- ASSERT (check (input, 2 * m - 1, expected, 2 * m - 1) == 0);
-
- free (input);
- }
+ size_t repeat = 1;
+ size_t m = 100000;
+ uint8_t *input = (uint8_t *) malloc (2 * (2 * m - 1) * sizeof (uint8_t));
+ if (input != NULL)
+ {
+ uint8_t *expected = input + (2 * m - 1);
+ size_t m1 = m / 2;
+ size_t m2 = (m - 1) / 2;
+ /* NB: m1 + m2 == m - 1. */
+ uint8_t *p;
+ size_t i;
+
+ input[0] = 0x41;
+ p = input + 1;
+ switch (pass)
+ {
+ case 0:
+ for (i = 0; i < m1; i++)
+ {
+ *p++ = 0xCC;
+ *p++ = 0x99;
+ }
+ for (i = 0; i < m2; i++)
+ {
+ *p++ = 0xCC;
+ *p++ = 0x80;
+ }
+ break;
+
+ case 1:
+ for (i = 0; i < m2; i++)
+ {
+ *p++ = 0xCC;
+ *p++ = 0x80;
+ }
+ for (i = 0; i < m1; i++)
+ {
+ *p++ = 0xCC;
+ *p++ = 0x99;
+ }
+ break;
+
+ case 2:
+ for (i = 0; i < m2; i++)
+ {
+ *p++ = 0xCC;
+ *p++ = 0x99;
+ *p++ = 0xCC;
+ *p++ = 0x80;
+ }
+ for (; i < m1; i++)
+ {
+ *p++ = 0xCC;
+ *p++ = 0x99;
+ }
+ break;
+
+ default:
+ abort ();
+ }
+
+ expected[0] = 0x41;
+ p = expected + 1;
+ for (i = 0; i < m1; i++)
+ {
+ *p++ = 0xCC;
+ *p++ = 0x99;
+ }
+ for (i = 0; i < m2; i++)
+ {
+ *p++ = 0xCC;
+ *p++ = 0x80;
+ }
+
+ for (; repeat > 0; repeat--)
+ ASSERT (check (input, 2 * m - 1, expected, 2 * m - 1) == 0);
+
+ free (input);
+ }
}
}
}
diff --git a/tests/uninorm/test-u8-nfkc.c b/tests/uninorm/test-u8-nfkc.c
index 0ea46363..1ca1413b 100644
--- a/tests/uninorm/test-u8-nfkc.c
+++ b/tests/uninorm/test-u8-nfkc.c
@@ -1,5 +1,5 @@
/* Test of compatibility normalization of UTF-8 strings.
- Copyright (C) 2009 Free Software Foundation, Inc.
+ Copyright (C) 2009, 2010 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -18,29 +18,16 @@
#include <config.h>
-#if GNULIB_UNINORM_U8_NORMALIZE
+#if GNULIB_TEST_UNINORM_U8_NORMALIZE
#include "uninorm.h"
#include <signal.h>
-#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include "unistr.h"
-
-#define SIZEOF(array) (sizeof (array) / sizeof (array[0]))
-#define ASSERT(expr) \
- do \
- { \
- if (!(expr)) \
- { \
- fprintf (stderr, "%s:%d: assertion failed\n", __FILE__, __LINE__); \
- fflush (stderr); \
- abort (); \
- } \
- } \
- while (0)
+#include "macros.h"
static int
check (const uint8_t *input, size_t input_length,
@@ -68,13 +55,13 @@ check (const uint8_t *input, size_t input_length,
preallocated = (uint8_t *) malloc (length * sizeof (uint8_t));
result = u8_normalize (UNINORM_NFKC, input, input_length, preallocated, &length);
if (!(result != NULL))
- return 4;
+ return 4;
if (!(result != preallocated))
- return 5;
+ return 5;
if (!(length == expected_length))
- return 6;
+ return 6;
if (!(u8_cmp (result, expected, expected_length) == 0))
- return 7;
+ return 7;
free (result);
free (preallocated);
}
@@ -257,8 +244,8 @@ test_u8_nfkc (void)
static const uint8_t input[] = { 0xEF, 0xB7, 0xBA };
static const uint8_t decomposed[] =
{ 0xD8, 0xB5, 0xD9, 0x84, 0xD9, 0x89, 0x20, 0xD8, 0xA7, 0xD9, 0x84, 0xD9,
- 0x84, 0xD9, 0x87, 0x20, 0xD8, 0xB9, 0xD9, 0x84, 0xD9, 0x8A, 0xD9, 0x87,
- 0x20, 0xD9, 0x88, 0xD8, 0xB3, 0xD9, 0x84, 0xD9, 0x85
+ 0x84, 0xD9, 0x87, 0x20, 0xD8, 0xB9, 0xD9, 0x84, 0xD9, 0x8A, 0xD9, 0x87,
+ 0x20, 0xD9, 0x88, 0xD8, 0xB3, 0xD9, 0x84, 0xD9, 0x85
};
ASSERT (check (input, SIZEOF (input), decomposed, SIZEOF (decomposed)) == 0);
ASSERT (check (decomposed, SIZEOF (decomposed), decomposed, SIZEOF (decomposed)) == 0);
@@ -282,36 +269,36 @@ test_u8_nfkc (void)
{ /* "Grüß Gott. Здравствуйте! x=(-b±sqrt(b²-4ac))/(2a) 日本語,中文,한글" */
static const uint8_t input[] =
{ 'G', 'r', 0xC3, 0xBC, 0xC3, 0x9F, ' ', 'G', 'o', 't', 't', '.',
- ' ', 0xD0, 0x97, 0xD0, 0xB4, 0xD1, 0x80, 0xD0, 0xB0, 0xD0, 0xB2, 0xD1,
- 0x81, 0xD1, 0x82, 0xD0, 0xB2, 0xD1, 0x83, 0xD0, 0xB9,
- 0xD1, 0x82, 0xD0, 0xB5, '!', ' ', 'x', '=', '(', '-', 'b', 0xC2, 0xB1,
- 's', 'q', 'r', 't', '(', 'b', 0xC2, 0xB2, '-', '4', 'a', 'c', ')', ')',
- '/', '(', '2', 'a', ')', ' ', ' ', 0xE6, 0x97, 0xA5, 0xE6, 0x9C, 0xAC,
- 0xE8, 0xAA, 0x9E, ',', 0xE4, 0xB8, 0xAD, 0xE6, 0x96, 0x87, ',',
- 0xED, 0x95, 0x9C,
- 0xEA, 0xB8, 0x80, '\n'
+ ' ', 0xD0, 0x97, 0xD0, 0xB4, 0xD1, 0x80, 0xD0, 0xB0, 0xD0, 0xB2, 0xD1,
+ 0x81, 0xD1, 0x82, 0xD0, 0xB2, 0xD1, 0x83, 0xD0, 0xB9,
+ 0xD1, 0x82, 0xD0, 0xB5, '!', ' ', 'x', '=', '(', '-', 'b', 0xC2, 0xB1,
+ 's', 'q', 'r', 't', '(', 'b', 0xC2, 0xB2, '-', '4', 'a', 'c', ')', ')',
+ '/', '(', '2', 'a', ')', ' ', ' ', 0xE6, 0x97, 0xA5, 0xE6, 0x9C, 0xAC,
+ 0xE8, 0xAA, 0x9E, ',', 0xE4, 0xB8, 0xAD, 0xE6, 0x96, 0x87, ',',
+ 0xED, 0x95, 0x9C,
+ 0xEA, 0xB8, 0x80, '\n'
};
static const uint8_t decomposed[] =
{ 'G', 'r', 0x75, 0xCC, 0x88, 0xC3, 0x9F, ' ', 'G', 'o', 't', 't', '.',
- ' ', 0xD0, 0x97, 0xD0, 0xB4, 0xD1, 0x80, 0xD0, 0xB0, 0xD0, 0xB2, 0xD1,
- 0x81, 0xD1, 0x82, 0xD0, 0xB2, 0xD1, 0x83, 0xD0, 0xB8, 0xCC, 0x86,
- 0xD1, 0x82, 0xD0, 0xB5, '!', ' ', 'x', '=', '(', '-', 'b', 0xC2, 0xB1,
- 's', 'q', 'r', 't', '(', 'b', 0x32, '-', '4', 'a', 'c', ')', ')',
- '/', '(', '2', 'a', ')', ' ', ' ', 0xE6, 0x97, 0xA5, 0xE6, 0x9C, 0xAC,
- 0xE8, 0xAA, 0x9E, ',', 0xE4, 0xB8, 0xAD, 0xE6, 0x96, 0x87, ',',
- 0xE1, 0x84, 0x92, 0xE1, 0x85, 0xA1, 0xE1, 0x86, 0xAB,
- 0xE1, 0x84, 0x80, 0xE1, 0x85, 0xB3, 0xE1, 0x86, 0xAF, '\n'
+ ' ', 0xD0, 0x97, 0xD0, 0xB4, 0xD1, 0x80, 0xD0, 0xB0, 0xD0, 0xB2, 0xD1,
+ 0x81, 0xD1, 0x82, 0xD0, 0xB2, 0xD1, 0x83, 0xD0, 0xB8, 0xCC, 0x86,
+ 0xD1, 0x82, 0xD0, 0xB5, '!', ' ', 'x', '=', '(', '-', 'b', 0xC2, 0xB1,
+ 's', 'q', 'r', 't', '(', 'b', 0x32, '-', '4', 'a', 'c', ')', ')',
+ '/', '(', '2', 'a', ')', ' ', ' ', 0xE6, 0x97, 0xA5, 0xE6, 0x9C, 0xAC,
+ 0xE8, 0xAA, 0x9E, ',', 0xE4, 0xB8, 0xAD, 0xE6, 0x96, 0x87, ',',
+ 0xE1, 0x84, 0x92, 0xE1, 0x85, 0xA1, 0xE1, 0x86, 0xAB,
+ 0xE1, 0x84, 0x80, 0xE1, 0x85, 0xB3, 0xE1, 0x86, 0xAF, '\n'
};
static const uint8_t expected[] =
{ 'G', 'r', 0xC3, 0xBC, 0xC3, 0x9F, ' ', 'G', 'o', 't', 't', '.',
- ' ', 0xD0, 0x97, 0xD0, 0xB4, 0xD1, 0x80, 0xD0, 0xB0, 0xD0, 0xB2, 0xD1,
- 0x81, 0xD1, 0x82, 0xD0, 0xB2, 0xD1, 0x83, 0xD0, 0xB9,
- 0xD1, 0x82, 0xD0, 0xB5, '!', ' ', 'x', '=', '(', '-', 'b', 0xC2, 0xB1,
- 's', 'q', 'r', 't', '(', 'b', 0x32, '-', '4', 'a', 'c', ')', ')',
- '/', '(', '2', 'a', ')', ' ', ' ', 0xE6, 0x97, 0xA5, 0xE6, 0x9C, 0xAC,
- 0xE8, 0xAA, 0x9E, ',', 0xE4, 0xB8, 0xAD, 0xE6, 0x96, 0x87, ',',
- 0xED, 0x95, 0x9C,
- 0xEA, 0xB8, 0x80, '\n'
+ ' ', 0xD0, 0x97, 0xD0, 0xB4, 0xD1, 0x80, 0xD0, 0xB0, 0xD0, 0xB2, 0xD1,
+ 0x81, 0xD1, 0x82, 0xD0, 0xB2, 0xD1, 0x83, 0xD0, 0xB9,
+ 0xD1, 0x82, 0xD0, 0xB5, '!', ' ', 'x', '=', '(', '-', 'b', 0xC2, 0xB1,
+ 's', 'q', 'r', 't', '(', 'b', 0x32, '-', '4', 'a', 'c', ')', ')',
+ '/', '(', '2', 'a', ')', ' ', ' ', 0xE6, 0x97, 0xA5, 0xE6, 0x9C, 0xAC,
+ 0xE8, 0xAA, 0x9E, ',', 0xE4, 0xB8, 0xAD, 0xE6, 0x96, 0x87, ',',
+ 0xED, 0x95, 0x9C,
+ 0xEA, 0xB8, 0x80, '\n'
};
ASSERT (check (input, SIZEOF (input), expected, SIZEOF (expected)) == 0);
ASSERT (check (decomposed, SIZEOF (decomposed), expected, SIZEOF (expected)) == 0);
@@ -330,89 +317,89 @@ test_u8_nfkc (void)
int pass;
for (pass = 0; pass < 3; pass++)
{
- size_t repeat = 1;
- size_t m = 100000;
- uint8_t *input = (uint8_t *) malloc (2 * (2 * m - 1) * sizeof (uint8_t));
- if (input != NULL)
- {
- uint8_t *expected = input + (2 * m - 1);
- size_t m1 = m / 2;
- size_t m2 = (m - 1) / 2;
- /* NB: m1 + m2 == m - 1. */
- uint8_t *p;
- size_t i;
-
- input[0] = 0x41;
- p = input + 1;
- switch (pass)
- {
- case 0:
- for (i = 0; i < m1; i++)
- {
- *p++ = 0xCC;
- *p++ = 0x99;
- }
- for (i = 0; i < m2; i++)
- {
- *p++ = 0xCC;
- *p++ = 0x80;
- }
- break;
-
- case 1:
- for (i = 0; i < m2; i++)
- {
- *p++ = 0xCC;
- *p++ = 0x80;
- }
- for (i = 0; i < m1; i++)
- {
- *p++ = 0xCC;
- *p++ = 0x99;
- }
- break;
-
- case 2:
- for (i = 0; i < m2; i++)
- {
- *p++ = 0xCC;
- *p++ = 0x99;
- *p++ = 0xCC;
- *p++ = 0x80;
- }
- for (; i < m1; i++)
- {
- *p++ = 0xCC;
- *p++ = 0x99;
- }
- break;
-
- default:
- abort ();
- }
-
- expected[0] = 0xC3;
- expected[1] = 0x80;
- p = expected + 2;
- for (i = 0; i < m1; i++)
- {
- *p++ = 0xCC;
- *p++ = 0x99;
- }
- for (i = 0; i < m2 - 1; i++)
- {
- *p++ = 0xCC;
- *p++ = 0x80;
- }
-
- for (; repeat > 0; repeat--)
- {
- ASSERT (check (input, 2 * m - 1, expected, 2 * m - 2) == 0);
- ASSERT (check (expected, 2 * m - 2, expected, 2 * m - 2) == 0);
- }
-
- free (input);
- }
+ size_t repeat = 1;
+ size_t m = 100000;
+ uint8_t *input = (uint8_t *) malloc (2 * (2 * m - 1) * sizeof (uint8_t));
+ if (input != NULL)
+ {
+ uint8_t *expected = input + (2 * m - 1);
+ size_t m1 = m / 2;
+ size_t m2 = (m - 1) / 2;
+ /* NB: m1 + m2 == m - 1. */
+ uint8_t *p;
+ size_t i;
+
+ input[0] = 0x41;
+ p = input + 1;
+ switch (pass)
+ {
+ case 0:
+ for (i = 0; i < m1; i++)
+ {
+ *p++ = 0xCC;
+ *p++ = 0x99;
+ }
+ for (i = 0; i < m2; i++)
+ {
+ *p++ = 0xCC;
+ *p++ = 0x80;
+ }
+ break;
+
+ case 1:
+ for (i = 0; i < m2; i++)
+ {
+ *p++ = 0xCC;
+ *p++ = 0x80;
+ }
+ for (i = 0; i < m1; i++)
+ {
+ *p++ = 0xCC;
+ *p++ = 0x99;
+ }
+ break;
+
+ case 2:
+ for (i = 0; i < m2; i++)
+ {
+ *p++ = 0xCC;
+ *p++ = 0x99;
+ *p++ = 0xCC;
+ *p++ = 0x80;
+ }
+ for (; i < m1; i++)
+ {
+ *p++ = 0xCC;
+ *p++ = 0x99;
+ }
+ break;
+
+ default:
+ abort ();
+ }
+
+ expected[0] = 0xC3;
+ expected[1] = 0x80;
+ p = expected + 2;
+ for (i = 0; i < m1; i++)
+ {
+ *p++ = 0xCC;
+ *p++ = 0x99;
+ }
+ for (i = 0; i < m2 - 1; i++)
+ {
+ *p++ = 0xCC;
+ *p++ = 0x80;
+ }
+
+ for (; repeat > 0; repeat--)
+ {
+ ASSERT (check (input, 2 * m - 1, expected, 2 * m - 2) == 0);
+ ASSERT (check (expected, 2 * m - 2, expected, 2 * m - 2) == 0);
+ }
+
+ free (input);
+ }
}
}
}
diff --git a/tests/uninorm/test-u8-nfkd.c b/tests/uninorm/test-u8-nfkd.c
index 2d883a05..2e295390 100644
--- a/tests/uninorm/test-u8-nfkd.c
+++ b/tests/uninorm/test-u8-nfkd.c
@@ -1,5 +1,5 @@
/* Test of compatibility decomposition of UTF-8 strings.
- Copyright (C) 2009 Free Software Foundation, Inc.
+ Copyright (C) 2009, 2010 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -18,29 +18,16 @@
#include <config.h>
-#if GNULIB_UNINORM_U8_NORMALIZE
+#if GNULIB_TEST_UNINORM_U8_NORMALIZE
#include "uninorm.h"
#include <signal.h>
-#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include "unistr.h"
-
-#define SIZEOF(array) (sizeof (array) / sizeof (array[0]))
-#define ASSERT(expr) \
- do \
- { \
- if (!(expr)) \
- { \
- fprintf (stderr, "%s:%d: assertion failed\n", __FILE__, __LINE__); \
- fflush (stderr); \
- abort (); \
- } \
- } \
- while (0)
+#include "macros.h"
static int
check (const uint8_t *input, size_t input_length,
@@ -68,13 +55,13 @@ check (const uint8_t *input, size_t input_length,
preallocated = (uint8_t *) malloc (length * sizeof (uint8_t));
result = u8_normalize (UNINORM_NFKD, input, input_length, preallocated, &length);
if (!(result != NULL))
- return 4;
+ return 4;
if (!(result != preallocated))
- return 5;
+ return 5;
if (!(length == expected_length))
- return 6;
+ return 6;
if (!(u8_cmp (result, expected, expected_length) == 0))
- return 7;
+ return 7;
free (result);
free (preallocated);
}
@@ -229,8 +216,8 @@ test_u8_nfkd (void)
static const uint8_t input[] = { 0xEF, 0xB7, 0xBA };
static const uint8_t expected[] =
{ 0xD8, 0xB5, 0xD9, 0x84, 0xD9, 0x89, 0x20, 0xD8, 0xA7, 0xD9, 0x84, 0xD9,
- 0x84, 0xD9, 0x87, 0x20, 0xD8, 0xB9, 0xD9, 0x84, 0xD9, 0x8A, 0xD9, 0x87,
- 0x20, 0xD9, 0x88, 0xD8, 0xB3, 0xD9, 0x84, 0xD9, 0x85
+ 0x84, 0xD9, 0x87, 0x20, 0xD8, 0xB9, 0xD9, 0x84, 0xD9, 0x8A, 0xD9, 0x87,
+ 0x20, 0xD9, 0x88, 0xD8, 0xB3, 0xD9, 0x84, 0xD9, 0x85
};
ASSERT (check (input, SIZEOF (input), expected, SIZEOF (expected)) == 0);
}
@@ -251,25 +238,25 @@ test_u8_nfkd (void)
{ /* "Grüß Gott. Здравствуйте! x=(-b±sqrt(b²-4ac))/(2a) 日本語,中文,한글" */
static const uint8_t input[] =
{ 'G', 'r', 0xC3, 0xBC, 0xC3, 0x9F, ' ', 'G', 'o', 't', 't', '.',
- ' ', 0xD0, 0x97, 0xD0, 0xB4, 0xD1, 0x80, 0xD0, 0xB0, 0xD0, 0xB2, 0xD1,
- 0x81, 0xD1, 0x82, 0xD0, 0xB2, 0xD1, 0x83, 0xD0, 0xB9,
- 0xD1, 0x82, 0xD0, 0xB5, '!', ' ', 'x', '=', '(', '-', 'b', 0xC2, 0xB1,
- 's', 'q', 'r', 't', '(', 'b', 0xC2, 0xB2, '-', '4', 'a', 'c', ')', ')',
- '/', '(', '2', 'a', ')', ' ', ' ', 0xE6, 0x97, 0xA5, 0xE6, 0x9C, 0xAC,
- 0xE8, 0xAA, 0x9E, ',', 0xE4, 0xB8, 0xAD, 0xE6, 0x96, 0x87, ',',
- 0xED, 0x95, 0x9C,
- 0xEA, 0xB8, 0x80, '\n'
+ ' ', 0xD0, 0x97, 0xD0, 0xB4, 0xD1, 0x80, 0xD0, 0xB0, 0xD0, 0xB2, 0xD1,
+ 0x81, 0xD1, 0x82, 0xD0, 0xB2, 0xD1, 0x83, 0xD0, 0xB9,
+ 0xD1, 0x82, 0xD0, 0xB5, '!', ' ', 'x', '=', '(', '-', 'b', 0xC2, 0xB1,
+ 's', 'q', 'r', 't', '(', 'b', 0xC2, 0xB2, '-', '4', 'a', 'c', ')', ')',
+ '/', '(', '2', 'a', ')', ' ', ' ', 0xE6, 0x97, 0xA5, 0xE6, 0x9C, 0xAC,
+ 0xE8, 0xAA, 0x9E, ',', 0xE4, 0xB8, 0xAD, 0xE6, 0x96, 0x87, ',',
+ 0xED, 0x95, 0x9C,
+ 0xEA, 0xB8, 0x80, '\n'
};
static const uint8_t expected[] =
{ 'G', 'r', 0x75, 0xCC, 0x88, 0xC3, 0x9F, ' ', 'G', 'o', 't', 't', '.',
- ' ', 0xD0, 0x97, 0xD0, 0xB4, 0xD1, 0x80, 0xD0, 0xB0, 0xD0, 0xB2, 0xD1,
- 0x81, 0xD1, 0x82, 0xD0, 0xB2, 0xD1, 0x83, 0xD0, 0xB8, 0xCC, 0x86,
- 0xD1, 0x82, 0xD0, 0xB5, '!', ' ', 'x', '=', '(', '-', 'b', 0xC2, 0xB1,
- 's', 'q', 'r', 't', '(', 'b', 0x32, '-', '4', 'a', 'c', ')', ')',
- '/', '(', '2', 'a', ')', ' ', ' ', 0xE6, 0x97, 0xA5, 0xE6, 0x9C, 0xAC,
- 0xE8, 0xAA, 0x9E, ',', 0xE4, 0xB8, 0xAD, 0xE6, 0x96, 0x87, ',',
- 0xE1, 0x84, 0x92, 0xE1, 0x85, 0xA1, 0xE1, 0x86, 0xAB,
- 0xE1, 0x84, 0x80, 0xE1, 0x85, 0xB3, 0xE1, 0x86, 0xAF, '\n'
+ ' ', 0xD0, 0x97, 0xD0, 0xB4, 0xD1, 0x80, 0xD0, 0xB0, 0xD0, 0xB2, 0xD1,
+ 0x81, 0xD1, 0x82, 0xD0, 0xB2, 0xD1, 0x83, 0xD0, 0xB8, 0xCC, 0x86,
+ 0xD1, 0x82, 0xD0, 0xB5, '!', ' ', 'x', '=', '(', '-', 'b', 0xC2, 0xB1,
+ 's', 'q', 'r', 't', '(', 'b', 0x32, '-', '4', 'a', 'c', ')', ')',
+ '/', '(', '2', 'a', ')', ' ', ' ', 0xE6, 0x97, 0xA5, 0xE6, 0x9C, 0xAC,
+ 0xE8, 0xAA, 0x9E, ',', 0xE4, 0xB8, 0xAD, 0xE6, 0x96, 0x87, ',',
+ 0xE1, 0x84, 0x92, 0xE1, 0x85, 0xA1, 0xE1, 0x86, 0xAB,
+ 0xE1, 0x84, 0x80, 0xE1, 0x85, 0xB3, 0xE1, 0x86, 0xAF, '\n'
};
ASSERT (check (input, SIZEOF (input), expected, SIZEOF (expected)) == 0);
}
@@ -286,85 +273,85 @@ test_u8_nfkd (void)
int pass;
for (pass = 0; pass < 3; pass++)
{
- size_t repeat = 1;
- size_t m = 100000;
- uint8_t *input = (uint8_t *) malloc (2 * (2 * m - 1) * sizeof (uint8_t));
- if (input != NULL)
- {
- uint8_t *expected = input + (2 * m - 1);
- size_t m1 = m / 2;
- size_t m2 = (m - 1) / 2;
- /* NB: m1 + m2 == m - 1. */
- uint8_t *p;
- size_t i;
-
- input[0] = 0x41;
- p = input + 1;
- switch (pass)
- {
- case 0:
- for (i = 0; i < m1; i++)
- {
- *p++ = 0xCC;
- *p++ = 0x99;
- }
- for (i = 0; i < m2; i++)
- {
- *p++ = 0xCC;
- *p++ = 0x80;
- }
- break;
-
- case 1:
- for (i = 0; i < m2; i++)
- {
- *p++ = 0xCC;
- *p++ = 0x80;
- }
- for (i = 0; i < m1; i++)
- {
- *p++ = 0xCC;
- *p++ = 0x99;
- }
- break;
-
- case 2:
- for (i = 0; i < m2; i++)
- {
- *p++ = 0xCC;
- *p++ = 0x99;
- *p++ = 0xCC;
- *p++ = 0x80;
- }
- for (; i < m1; i++)
- {
- *p++ = 0xCC;
- *p++ = 0x99;
- }
- break;
-
- default:
- abort ();
- }
-
- expected[0] = 0x41;
- p = expected + 1;
- for (i = 0; i < m1; i++)
- {
- *p++ = 0xCC;
- *p++ = 0x99;
- }
- for (i = 0; i < m2; i++)
- {
- *p++ = 0xCC;
- *p++ = 0x80;
- }
-
- for (; repeat > 0; repeat--)
- ASSERT (check (input, 2 * m - 1, expected, 2 * m - 1) == 0);
-
- free (input);
- }
+ size_t repeat = 1;
+ size_t m = 100000;
+ uint8_t *input = (uint8_t *) malloc (2 * (2 * m - 1) * sizeof (uint8_t));
+ if (input != NULL)
+ {
+ uint8_t *expected = input + (2 * m - 1);
+ size_t m1 = m / 2;
+ size_t m2 = (m - 1) / 2;
+ /* NB: m1 + m2 == m - 1. */
+ uint8_t *p;
+ size_t i;
+
+ input[0] = 0x41;
+ p = input + 1;
+ switch (pass)
+ {
+ case 0:
+ for (i = 0; i < m1; i++)
+ {
+ *p++ = 0xCC;
+ *p++ = 0x99;
+ }
+ for (i = 0; i < m2; i++)
+ {
+ *p++ = 0xCC;
+ *p++ = 0x80;
+ }
+ break;
+
+ case 1:
+ for (i = 0; i < m2; i++)
+ {
+ *p++ = 0xCC;
+ *p++ = 0x80;
+ }
+ for (i = 0; i < m1; i++)
+ {
+ *p++ = 0xCC;
+ *p++ = 0x99;
+ }
+ break;
+
+ case 2:
+ for (i = 0; i < m2; i++)
+ {
+ *p++ = 0xCC;
+ *p++ = 0x99;
+ *p++ = 0xCC;
+ *p++ = 0x80;
+ }
+ for (; i < m1; i++)
+ {
+ *p++ = 0xCC;
+ *p++ = 0x99;
+ }
+ break;
+
+ default:
+ abort ();
+ }
+
+ expected[0] = 0x41;
+ p = expected + 1;
+ for (i = 0; i < m1; i++)
+ {
+ *p++ = 0xCC;
+ *p++ = 0x99;
+ }
+ for (i = 0; i < m2; i++)
+ {
+ *p++ = 0xCC;
+ *p++ = 0x80;
+ }
+
+ for (; repeat > 0; repeat--)
+ ASSERT (check (input, 2 * m - 1, expected, 2 * m - 1) == 0);
+
+ free (input);
+ }
}
}
}
diff --git a/tests/uninorm/test-u8-normcmp.c b/tests/uninorm/test-u8-normcmp.c
index ec479472..4f09118f 100644
--- a/tests/uninorm/test-u8-normcmp.c
+++ b/tests/uninorm/test-u8-normcmp.c
@@ -1,5 +1,5 @@
/* Test of normalization insensitive comparison of UTF-8 strings.
- Copyright (C) 2009 Free Software Foundation, Inc.
+ Copyright (C) 2009, 2010 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -20,21 +20,7 @@
#include "uninorm.h"
-#include <stdio.h>
-#include <stdlib.h>
-
-#define SIZEOF(array) (sizeof (array) / sizeof (array[0]))
-#define ASSERT(expr) \
- do \
- { \
- if (!(expr)) \
- { \
- fprintf (stderr, "%s:%d: assertion failed\n", __FILE__, __LINE__); \
- fflush (stderr); \
- abort (); \
- } \
- } \
- while (0)
+#include "macros.h"
#include "test-u8-normcmp.h"
diff --git a/tests/uninorm/test-u8-normcmp.h b/tests/uninorm/test-u8-normcmp.h
index 78c887d2..790e3ae2 100644
--- a/tests/uninorm/test-u8-normcmp.h
+++ b/tests/uninorm/test-u8-normcmp.h
@@ -1,5 +1,5 @@
/* Test of normalization insensitive comparison of UTF-8 strings.
- Copyright (C) 2009 Free Software Foundation, Inc.
+ Copyright (C) 2009, 2010 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -18,7 +18,7 @@
static void
test_ascii (int (*my_normcmp) (const uint8_t *, size_t, const uint8_t *, size_t, uninorm_t, int *),
- uninorm_t nf)
+ uninorm_t nf)
{
/* Empty string. */
{
diff --git a/tests/uninorm/test-u8-normcoll.c b/tests/uninorm/test-u8-normcoll.c
index edf91720..d205f286 100644
--- a/tests/uninorm/test-u8-normcoll.c
+++ b/tests/uninorm/test-u8-normcoll.c
@@ -1,6 +1,6 @@
/* Test of locale dependent, normalization insensitive comparison of
UTF-8 strings.
- Copyright (C) 2009 Free Software Foundation, Inc.
+ Copyright (C) 2009, 2010 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -21,21 +21,7 @@
#include "uninorm.h"
-#include <stdio.h>
-#include <stdlib.h>
-
-#define SIZEOF(array) (sizeof (array) / sizeof (array[0]))
-#define ASSERT(expr) \
- do \
- { \
- if (!(expr)) \
- { \
- fprintf (stderr, "%s:%d: assertion failed\n", __FILE__, __LINE__); \
- fflush (stderr); \
- abort (); \
- } \
- } \
- while (0)
+#include "macros.h"
#include "test-u8-normcmp.h"
int
diff --git a/tests/uninorm/test-uninorm-filter-nfc.c b/tests/uninorm/test-uninorm-filter-nfc.c
index 32b77efa..65bf8a95 100644
--- a/tests/uninorm/test-uninorm-filter-nfc.c
+++ b/tests/uninorm/test-uninorm-filter-nfc.c
@@ -1,5 +1,5 @@
/* Test of canonical normalization of streams.
- Copyright (C) 2009 Free Software Foundation, Inc.
+ Copyright (C) 2009, 2010 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -20,23 +20,10 @@
#include "uninorm.h"
-#include <stdio.h>
#include <stdlib.h>
#include "unistr.h"
-
-#define SIZEOF(array) (sizeof (array) / sizeof (array[0]))
-#define ASSERT(expr) \
- do \
- { \
- if (!(expr)) \
- { \
- fprintf (stderr, "%s:%d: assertion failed\n", __FILE__, __LINE__); \
- fflush (stderr); \
- abort (); \
- } \
- } \
- while (0)
+#include "macros.h"
/* A stream of Unicode characters that simply accumulates the contents. */
@@ -99,20 +86,20 @@ main ()
{ /* "Grüß Gott. Здравствуйте! x=(-b±sqrt(b²-4ac))/(2a) 日本語,中文,한글" */
static const uint32_t input[] =
{ 'G', 'r', 0x00FC, 0x00DF, ' ', 'G', 'o', 't', 't', '.', ' ',
- 0x0417, 0x0434, 0x0440, 0x0430, 0x0432, 0x0441, 0x0442, 0x0432, 0x0443,
- 0x0439, 0x0442, 0x0435, '!', ' ',
- 'x', '=', '(', '-', 'b', 0x00B1, 's', 'q', 'r', 't', '(', 'b', 0x00B2,
- '-', '4', 'a', 'c', ')', ')', '/', '(', '2', 'a', ')', ' ', ' ',
- 0x65E5, 0x672C, 0x8A9E, ',', 0x4E2D, 0x6587, ',', 0xD55C, 0xAE00, '\n'
+ 0x0417, 0x0434, 0x0440, 0x0430, 0x0432, 0x0441, 0x0442, 0x0432, 0x0443,
+ 0x0439, 0x0442, 0x0435, '!', ' ',
+ 'x', '=', '(', '-', 'b', 0x00B1, 's', 'q', 'r', 't', '(', 'b', 0x00B2,
+ '-', '4', 'a', 'c', ')', ')', '/', '(', '2', 'a', ')', ' ', ' ',
+ 0x65E5, 0x672C, 0x8A9E, ',', 0x4E2D, 0x6587, ',', 0xD55C, 0xAE00, '\n'
};
static const uint32_t decomposed[] =
{ 'G', 'r', 0x0075, 0x0308, 0x00DF, ' ', 'G', 'o', 't', 't', '.', ' ',
- 0x0417, 0x0434, 0x0440, 0x0430, 0x0432, 0x0441, 0x0442, 0x0432, 0x0443,
- 0x0438, 0x0306, 0x0442, 0x0435, '!', ' ',
- 'x', '=', '(', '-', 'b', 0x00B1, 's', 'q', 'r', 't', '(', 'b', 0x00B2,
- '-', '4', 'a', 'c', ')', ')', '/', '(', '2', 'a', ')', ' ', ' ',
- 0x65E5, 0x672C, 0x8A9E, ',', 0x4E2D, 0x6587, ',',
- 0x1112, 0x1161, 0x11AB, 0x1100, 0x1173, 0x11AF, '\n'
+ 0x0417, 0x0434, 0x0440, 0x0430, 0x0432, 0x0441, 0x0442, 0x0432, 0x0443,
+ 0x0438, 0x0306, 0x0442, 0x0435, '!', ' ',
+ 'x', '=', '(', '-', 'b', 0x00B1, 's', 'q', 'r', 't', '(', 'b', 0x00B2,
+ '-', '4', 'a', 'c', ')', ')', '/', '(', '2', 'a', ')', ' ', ' ',
+ 0x65E5, 0x672C, 0x8A9E, ',', 0x4E2D, 0x6587, ',',
+ 0x1112, 0x1161, 0x11AB, 0x1100, 0x1173, 0x11AF, '\n'
};
ASSERT (check (input, SIZEOF (input), input, SIZEOF (input)) == 0);
ASSERT (check (decomposed, SIZEOF (decomposed), input, SIZEOF (input)) == 0);