diff options
| author | Jörg Frings-Fürst <debian@jff.email> | 2026-03-08 17:28:33 +0100 |
|---|---|---|
| committer | Jörg Frings-Fürst <debian@jff.email> | 2026-03-08 17:28:33 +0100 |
| commit | 5f59a34ab747dde8ede7357f3431bf06bd6002fe (patch) | |
| tree | 056a4477fd870d454d5be5868cddab829a47f4d2 /tests/uninorm/test-u8-nfkc.c | |
| parent | 27dae84ed92f1ef0300263091972338d12e78348 (diff) | |
New upstream version 1.4.2upstream/1.4.2upstream
Diffstat (limited to 'tests/uninorm/test-u8-nfkc.c')
| -rw-r--r-- | tests/uninorm/test-u8-nfkc.c | 176 |
1 files changed, 86 insertions, 90 deletions
diff --git a/tests/uninorm/test-u8-nfkc.c b/tests/uninorm/test-u8-nfkc.c index a8379908..551d112f 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-2025 Free Software Foundation, Inc. + Copyright (C) 2009-2026 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 @@ -314,95 +314,91 @@ test_u8_nfkc (void) #endif /* Check that the sorting is not O(n²) but O(n log n). */ - { - 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); - } - } - } + for (int 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; + + input[0] = 0x41; + p = input + 1; + switch (pass) + { + case 0: + for (size_t i = 0; i < m1; i++) + { + *p++ = 0xCC; + *p++ = 0x99; + } + for (size_t i = 0; i < m2; i++) + { + *p++ = 0xCC; + *p++ = 0x80; + } + break; + + case 1: + for (size_t i = 0; i < m2; i++) + { + *p++ = 0xCC; + *p++ = 0x80; + } + for (size_t i = 0; i < m1; i++) + { + *p++ = 0xCC; + *p++ = 0x99; + } + break; + + case 2: + for (size_t i = 0; i < m2; i++) + { + *p++ = 0xCC; + *p++ = 0x99; + *p++ = 0xCC; + *p++ = 0x80; + } + for (size_t i = m2; i < m1; i++) + { + *p++ = 0xCC; + *p++ = 0x99; + } + break; + + default: + abort (); + } + + expected[0] = 0xC3; + expected[1] = 0x80; + p = expected + 2; + for (size_t i = 0; i < m1; i++) + { + *p++ = 0xCC; + *p++ = 0x99; + } + for (size_t 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); + } + } } #else |
