Mercurial > hg > octave-lyh > gnulib-hg
changeset 13471:7ade914695f0
unistr/u*-chr: prepare for multibyte tests
* modules/unistr/u16-chr-tests: Depend on u32-to-u16.
* modules/unistr/u8-chr-tests: Depend on u32-to-u8.
* tests/unistr/test-chr.h: Build initial version as UCS-4 then convert.
* tests/unistr/test-u16-chr.c, tests/unistr/test-u32-chr.c,
tests/unistr/test-u8-chr.c: Define U32_TO_U.
author | Paolo Bonzini <pbonzini@redhat.com> |
---|---|
date | Tue, 20 Jul 2010 16:06:33 +0200 |
parents | f309a1831a56 |
children | 5538ea968fcb |
files | modules/unistr/u16-chr-tests modules/unistr/u8-chr-tests tests/unistr/test-chr.h tests/unistr/test-u16-chr.c tests/unistr/test-u32-chr.c tests/unistr/test-u8-chr.c |
diffstat | 6 files changed, 18 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/modules/unistr/u16-chr-tests +++ b/modules/unistr/u16-chr-tests @@ -9,6 +9,7 @@ extensions getpagesize unistr/u16-set +unistr/u32-to-u16 configure.ac: gl_FUNC_MMAP_ANON
--- a/modules/unistr/u8-chr-tests +++ b/modules/unistr/u8-chr-tests @@ -9,6 +9,7 @@ extensions getpagesize unistr/u8-set +unistr/u32-to-u8 configure.ac: gl_FUNC_MMAP_ANON
--- a/tests/unistr/test-chr.h +++ b/tests/unistr/test-chr.h @@ -20,15 +20,20 @@ main (void) { size_t n = 0x100000; - UNIT *input = (UNIT *) malloc (n * sizeof (UNIT)); - ASSERT (input); + size_t length; + UNIT *input; + uint32_t *input32 = (uint32_t *) malloc (n * sizeof (uint32_t)); + ASSERT (input32); - input[0] = 'a'; - input[1] = 'b'; - U_SET (input + 2, 'c', 1024); - U_SET (input + 1026, 'd', n - 1028); - input[n - 2] = 'e'; - input[n - 1] = 'a'; + input32[0] = 'a'; + input32[1] = 'b'; + u32_set (input32 + 2, 'c', 1024); + u32_set (input32 + 1026, 'd', n - 1028); + input32[n - 2] = 'e'; + input32[n - 1] = 'a'; + + input = U32_TO_U (input32, n, NULL, &length); + ASSERT (input); /* Basic behavior tests. */ ASSERT (U_CHR (input, n, 'a') == input);
--- a/tests/unistr/test-u16-chr.c +++ b/tests/unistr/test-u16-chr.c @@ -26,6 +26,7 @@ #include "macros.h" #define UNIT uint16_t +#define U32_TO_U u32_to_u16 #define U_CHR u16_chr #define U_SET u16_set #include "test-chr.h"