diff options
author | Andreas Rottmann <a.rottmann@gmx.at> | 2010-05-27 18:23:17 +0200 |
---|---|---|
committer | Andreas Rottmann <a.rottmann@gmx.at> | 2010-05-27 18:23:17 +0200 |
commit | bd6adfa17d453e4c486e36fed4c5779db90a8a0e (patch) | |
tree | 9798677560d5f99061afe9f0db105a8c97f2438a /tests/unistdio | |
parent | 79ca645d222db2e158784642c3b464a47bea26f3 (diff) | |
parent | 3e0814cd9862b89c7a39672672937477bd87ddfb (diff) |
Merge commit 'upstream/0.9.3'
Diffstat (limited to 'tests/unistdio')
36 files changed, 680 insertions, 1039 deletions
diff --git a/tests/unistdio/test-u16-asnprintf1.c b/tests/unistdio/test-u16-asnprintf1.c index 53fedf3..3d4897c 100644 --- a/tests/unistdio/test-u16-asnprintf1.c +++ b/tests/unistdio/test-u16-asnprintf1.c @@ -1,5 +1,5 @@ /* Test of u16_asnprintf() function. - Copyright (C) 2007-2008 Free Software Foundation, Inc. + Copyright (C) 2007-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 @@ -23,25 +23,12 @@ #include <errno.h> #include <stdarg.h> #include <stddef.h> -#include <stdio.h> #include <stdint.h> #include <stdlib.h> #include <string.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" #include "test-u16-asnprintf1.h" diff --git a/tests/unistdio/test-u16-asnprintf1.h b/tests/unistdio/test-u16-asnprintf1.h index 34d4f82..9d557ba 100644 --- a/tests/unistdio/test-u16-asnprintf1.h +++ b/tests/unistdio/test-u16-asnprintf1.h @@ -1,5 +1,5 @@ /* Test of u16_[v]asnprintf() function. - Copyright (C) 2007 Free Software Foundation, Inc. + Copyright (C) 2007, 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 @@ -29,7 +29,7 @@ test_function (uint16_t * (*my_asnprintf) (uint16_t *, size_t *, const char *, . size_t length = size; uint16_t *result = my_asnprintf (NULL, &length, "%d", 12345); static const uint16_t expected[] = - { '1', '2', '3', '4', '5', 0 }; + { '1', '2', '3', '4', '5', 0 }; ASSERT (result != NULL); ASSERT (u16_strcmp (result, expected) == 0); ASSERT (length == 5); @@ -39,9 +39,9 @@ test_function (uint16_t * (*my_asnprintf) (uint16_t *, size_t *, const char *, . for (size = 0; size <= 8; size++) { static const uint16_t initializer[] = - { 'D', 'E', 'A', 'D', 'B', 'E', 'E', 'F', 0 }; + { 'D', 'E', 'A', 'D', 'B', 'E', 'E', 'F', 0 }; static const uint16_t expected[] = - { '1', '2', '3', '4', '5', 0 }; + { '1', '2', '3', '4', '5', 0 }; size_t length; uint16_t *result; @@ -52,9 +52,9 @@ test_function (uint16_t * (*my_asnprintf) (uint16_t *, size_t *, const char *, . ASSERT (u16_strcmp (result, expected) == 0); ASSERT (length == 5); if (size < 6) - ASSERT (result != buf); + ASSERT (result != buf); ASSERT (u16_cmp (buf + size, initializer + size, 8 - size) == 0); if (result != buf) - free (result); + free (result); } } diff --git a/tests/unistdio/test-u16-printf1.h b/tests/unistdio/test-u16-printf1.h index 199ece9..1965ce9 100644 --- a/tests/unistdio/test-u16-printf1.h +++ b/tests/unistdio/test-u16-printf1.h @@ -1,5 +1,5 @@ /* Test of u16_v[a]s[n]printf() function. - Copyright (C) 2007 Free Software Foundation, Inc. + Copyright (C) 2007, 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 @@ -67,36 +67,36 @@ test_xfunction (uint16_t * (*my_xasprintf) (const char *, ...)) static const uint8_t unicode_string[] = "Hello"; { uint16_t *result = - my_xasprintf ("%U %d", unicode_string, 33, 44, 55); + my_xasprintf ("%U %d", unicode_string, 33, 44, 55); static const uint16_t expected[] = - { 'H', 'e', 'l', 'l', 'o', ' ', '3', '3', 0 }; + { 'H', 'e', 'l', 'l', 'o', ' ', '3', '3', 0 }; ASSERT (result != NULL); ASSERT (u16_strcmp (result, expected) == 0); free (result); } { /* Width. */ uint16_t *result = - my_xasprintf ("%10U %d", unicode_string, 33, 44, 55); + my_xasprintf ("%10U %d", unicode_string, 33, 44, 55); static const uint16_t expected[] = - { ' ', ' ', ' ', ' ', ' ', 'H', 'e', 'l', 'l', 'o', ' ', '3', '3', 0 }; + { ' ', ' ', ' ', ' ', ' ', 'H', 'e', 'l', 'l', 'o', ' ', '3', '3', 0 }; ASSERT (result != NULL); ASSERT (u16_strcmp (result, expected) == 0); free (result); } { /* FLAG_LEFT. */ uint16_t *result = - my_xasprintf ("%-10U %d", unicode_string, 33, 44, 55); + my_xasprintf ("%-10U %d", unicode_string, 33, 44, 55); static const uint16_t expected[] = - { 'H', 'e', 'l', 'l', 'o', ' ', ' ', ' ', ' ', ' ', ' ', '3', '3', 0 }; + { 'H', 'e', 'l', 'l', 'o', ' ', ' ', ' ', ' ', ' ', ' ', '3', '3', 0 }; ASSERT (result != NULL); ASSERT (u16_strcmp (result, expected) == 0); free (result); } { /* FLAG_ZERO: no effect. */ uint16_t *result = - my_xasprintf ("%010U %d", unicode_string, 33, 44, 55); + my_xasprintf ("%010U %d", unicode_string, 33, 44, 55); static const uint16_t expected[] = - { ' ', ' ', ' ', ' ', ' ', 'H', 'e', 'l', 'l', 'o', ' ', '3', '3', 0 }; + { ' ', ' ', ' ', ' ', ' ', 'H', 'e', 'l', 'l', 'o', ' ', '3', '3', 0 }; ASSERT (result != NULL); ASSERT (u16_strcmp (result, expected) == 0); free (result); @@ -107,36 +107,36 @@ test_xfunction (uint16_t * (*my_xasprintf) (const char *, ...)) static const uint16_t unicode_string[] = { 'H', 'e', 'l', 'l', 'o', 0 }; { uint16_t *result = - my_xasprintf ("%lU %d", unicode_string, 33, 44, 55); + my_xasprintf ("%lU %d", unicode_string, 33, 44, 55); static const uint16_t expected[] = - { 'H', 'e', 'l', 'l', 'o', ' ', '3', '3', 0 }; + { 'H', 'e', 'l', 'l', 'o', ' ', '3', '3', 0 }; ASSERT (result != NULL); ASSERT (u16_strcmp (result, expected) == 0); free (result); } { /* Width. */ uint16_t *result = - my_xasprintf ("%10lU %d", unicode_string, 33, 44, 55); + my_xasprintf ("%10lU %d", unicode_string, 33, 44, 55); static const uint16_t expected[] = - { ' ', ' ', ' ', ' ', ' ', 'H', 'e', 'l', 'l', 'o', ' ', '3', '3', 0 }; + { ' ', ' ', ' ', ' ', ' ', 'H', 'e', 'l', 'l', 'o', ' ', '3', '3', 0 }; ASSERT (result != NULL); ASSERT (u16_strcmp (result, expected) == 0); free (result); } { /* FLAG_LEFT. */ uint16_t *result = - my_xasprintf ("%-10lU %d", unicode_string, 33, 44, 55); + my_xasprintf ("%-10lU %d", unicode_string, 33, 44, 55); static const uint16_t expected[] = - { 'H', 'e', 'l', 'l', 'o', ' ', ' ', ' ', ' ', ' ', ' ', '3', '3', 0 }; + { 'H', 'e', 'l', 'l', 'o', ' ', ' ', ' ', ' ', ' ', ' ', '3', '3', 0 }; ASSERT (result != NULL); ASSERT (u16_strcmp (result, expected) == 0); free (result); } { /* FLAG_ZERO: no effect. */ uint16_t *result = - my_xasprintf ("%010lU %d", unicode_string, 33, 44, 55); + my_xasprintf ("%010lU %d", unicode_string, 33, 44, 55); static const uint16_t expected[] = - { ' ', ' ', ' ', ' ', ' ', 'H', 'e', 'l', 'l', 'o', ' ', '3', '3', 0 }; + { ' ', ' ', ' ', ' ', ' ', 'H', 'e', 'l', 'l', 'o', ' ', '3', '3', 0 }; ASSERT (result != NULL); ASSERT (u16_strcmp (result, expected) == 0); free (result); @@ -147,36 +147,36 @@ test_xfunction (uint16_t * (*my_xasprintf) (const char *, ...)) static const uint32_t unicode_string[] = { 'H', 'e', 'l', 'l', 'o', 0 }; { uint16_t *result = - my_xasprintf ("%llU %d", unicode_string, 33, 44, 55); + my_xasprintf ("%llU %d", unicode_string, 33, 44, 55); static const uint16_t expected[] = - { 'H', 'e', 'l', 'l', 'o', ' ', '3', '3', 0 }; + { 'H', 'e', 'l', 'l', 'o', ' ', '3', '3', 0 }; ASSERT (result != NULL); ASSERT (u16_strcmp (result, expected) == 0); free (result); } { /* Width. */ uint16_t *result = - my_xasprintf ("%10llU %d", unicode_string, 33, 44, 55); + my_xasprintf ("%10llU %d", unicode_string, 33, 44, 55); static const uint16_t expected[] = - { ' ', ' ', ' ', ' ', ' ', 'H', 'e', 'l', 'l', 'o', ' ', '3', '3', 0 }; + { ' ', ' ', ' ', ' ', ' ', 'H', 'e', 'l', 'l', 'o', ' ', '3', '3', 0 }; ASSERT (result != NULL); ASSERT (u16_strcmp (result, expected) == 0); free (result); } { /* FLAG_LEFT. */ uint16_t *result = - my_xasprintf ("%-10llU %d", unicode_string, 33, 44, 55); + my_xasprintf ("%-10llU %d", unicode_string, 33, 44, 55); static const uint16_t expected[] = - { 'H', 'e', 'l', 'l', 'o', ' ', ' ', ' ', ' ', ' ', ' ', '3', '3', 0 }; + { 'H', 'e', 'l', 'l', 'o', ' ', ' ', ' ', ' ', ' ', ' ', '3', '3', 0 }; ASSERT (result != NULL); ASSERT (u16_strcmp (result, expected) == 0); free (result); } { /* FLAG_ZERO: no effect. */ uint16_t *result = - my_xasprintf ("%010llU %d", unicode_string, 33, 44, 55); + my_xasprintf ("%010llU %d", unicode_string, 33, 44, 55); static const uint16_t expected[] = - { ' ', ' ', ' ', ' ', ' ', 'H', 'e', 'l', 'l', 'o', ' ', '3', '3', 0 }; + { ' ', ' ', ' ', ' ', ' ', 'H', 'e', 'l', 'l', 'o', ' ', '3', '3', 0 }; ASSERT (result != NULL); ASSERT (u16_strcmp (result, expected) == 0); free (result); @@ -190,8 +190,8 @@ test_xfunction (uint16_t * (*my_xasprintf) (const char *, ...)) my_xasprintf ("Mr. %s %d", "Ronald Reagan", 33, 44, 55); static const uint16_t expected[] = { 'M', 'r', '.', ' ', 'R', 'o', 'n', 'a', 'l', 'd', - ' ', 'R', 'e', 'a', 'g', 'a', 'n', ' ', '3', '3', - 0 + ' ', 'R', 'e', 'a', 'g', 'a', 'n', ' ', '3', '3', + 0 }; ASSERT (result != NULL); ASSERT (u16_strcmp (result, expected) == 0); @@ -203,8 +203,8 @@ test_xfunction (uint16_t * (*my_xasprintf) (const char *, ...)) my_xasprintf ("Mr. %20s %d", "Ronald Reagan", 33, 44, 55); static const uint16_t expected[] = { 'M', 'r', '.', ' ', ' ', ' ', ' ', ' ', ' ', ' ', - ' ', 'R', 'o', 'n', 'a', 'l', 'd', ' ', 'R', 'e', - 'a', 'g', 'a', 'n', ' ', '3', '3', 0 + ' ', 'R', 'o', 'n', 'a', 'l', 'd', ' ', 'R', 'e', + 'a', 'g', 'a', 'n', ' ', '3', '3', 0 }; ASSERT (result != NULL); ASSERT (u16_strcmp (result, expected) == 0); @@ -216,8 +216,8 @@ test_xfunction (uint16_t * (*my_xasprintf) (const char *, ...)) my_xasprintf ("Mr. %-20s %d", "Ronald Reagan", 33, 44, 55); static const uint16_t expected[] = { 'M', 'r', '.', ' ', 'R', 'o', 'n', 'a', 'l', 'd', - ' ', 'R', 'e', 'a', 'g', 'a', 'n', ' ', ' ', ' ', - ' ', ' ', ' ', ' ', ' ', '3', '3', 0 + ' ', 'R', 'e', 'a', 'g', 'a', 'n', ' ', ' ', ' ', + ' ', ' ', ' ', ' ', ' ', '3', '3', 0 }; ASSERT (result != NULL); ASSERT (u16_strcmp (result, expected) == 0); @@ -229,8 +229,8 @@ test_xfunction (uint16_t * (*my_xasprintf) (const char *, ...)) my_xasprintf ("Mr. %020s %d", "Ronald Reagan", 33, 44, 55); static const uint16_t expected[] = { 'M', 'r', '.', ' ', ' ', ' ', ' ', ' ', ' ', ' ', - ' ', 'R', 'o', 'n', 'a', 'l', 'd', ' ', 'R', 'e', - 'a', 'g', 'a', 'n', ' ', '3', '3', 0 + ' ', 'R', 'o', 'n', 'a', 'l', 'd', ' ', 'R', 'e', + 'a', 'g', 'a', 'n', ' ', '3', '3', 0 }; ASSERT (result != NULL); ASSERT (u16_strcmp (result, expected) == 0); @@ -253,9 +253,9 @@ test_xfunction (uint16_t * (*my_xasprintf) (const char *, ...)) { '0', 'x', 'c', '.', '9', '1', 'p', '-', '2', ' ', '3', '3', 0 }; ASSERT (result != NULL); ASSERT (u16_strcmp (result, expected1) == 0 - || u16_strcmp (result, expected2) == 0 - || u16_strcmp (result, expected3) == 0 - || u16_strcmp (result, expected4) == 0); + || u16_strcmp (result, expected2) == 0 + || u16_strcmp (result, expected3) == 0 + || u16_strcmp (result, expected4) == 0); free (result); } @@ -272,9 +272,9 @@ test_xfunction (uint16_t * (*my_xasprintf) (const char *, ...)) { ' ', ' ', ' ', ' ', '0', 'x', 'e', 'p', '-', '3', ' ', '3', '3', 0 }; ASSERT (result != NULL); ASSERT (u16_strcmp (result, expected1) == 0 - || u16_strcmp (result, expected2) == 0 - || u16_strcmp (result, expected3) == 0 - || u16_strcmp (result, expected4) == 0); + || u16_strcmp (result, expected2) == 0 + || u16_strcmp (result, expected3) == 0 + || u16_strcmp (result, expected4) == 0); free (result); } @@ -283,29 +283,29 @@ test_xfunction (uint16_t * (*my_xasprintf) (const char *, ...)) my_xasprintf ("%.10a %d", 1.75, 33, 44, 55); static const uint16_t expected1[] = { '0', 'x', '1', '.', 'c', '0', '0', '0', '0', '0', - '0', '0', '0', '0', 'p', '+', '0', ' ', '3', '3', - 0 + '0', '0', '0', '0', 'p', '+', '0', ' ', '3', '3', + 0 }; static const uint16_t expected2[] = { '0', 'x', '3', '.', '8', '0', '0', '0', '0', '0', - '0', '0', '0', '0', 'p', '-', '1', ' ', '3', '3', - 0 + '0', '0', '0', '0', 'p', '-', '1', ' ', '3', '3', + 0 }; static const uint16_t expected3[] = { '0', 'x', '7', '.', '0', '0', '0', '0', '0', '0', - '0', '0', '0', '0', 'p', '-', '2', ' ', '3', '3', - 0 + '0', '0', '0', '0', 'p', '-', '2', ' ', '3', '3', + 0 }; static const uint16_t expected4[] = { '0', 'x', 'e', '.', '0', '0', '0', '0', '0', '0', - '0', '0', '0', '0', 'p', '-', '3', ' ', '3', '3', - 0 + '0', '0', '0', '0', 'p', '-', '3', ' ', '3', '3', + 0 }; ASSERT (result != NULL); ASSERT (u16_strcmp (result, expected1) == 0 - || u16_strcmp (result, expected2) == 0 - || u16_strcmp (result, expected3) == 0 - || u16_strcmp (result, expected4) == 0); + || u16_strcmp (result, expected2) == 0 + || u16_strcmp (result, expected3) == 0 + || u16_strcmp (result, expected4) == 0); free (result); } @@ -314,45 +314,45 @@ test_xfunction (uint16_t * (*my_xasprintf) (const char *, ...)) my_xasprintf ("%.50a %d", 1.75, 33, 44, 55); static const uint16_t expected1[] = { '0', 'x', '1', '.', 'c', '0', '0', '0', '0', '0', - '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', - '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', - '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', - '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', - '0', '0', '0', '0', 'p', '+', '0', ' ', '3', '3', - 0 + '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', + '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', + '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', + '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', + '0', '0', '0', '0', 'p', '+', '0', ' ', '3', '3', + 0 }; static const uint16_t expected2[] = { '0', 'x', '3', '.', '8', '0', '0', '0', '0', '0', - '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', - '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', - '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', - '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', - '0', '0', '0', '0', 'p', '-', '1', ' ', '3', '3', - 0 + '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', + '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', + '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', + '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', + '0', '0', '0', '0', 'p', '-', '1', ' ', '3', '3', + 0 }; static const uint16_t expected3[] = { '0', 'x', '7', '.', '0', '0', '0', '0', '0', '0', - '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', - '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', - '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', - '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', - '0', '0', '0', '0', 'p', '-', '2', ' ', '3', '3', - 0 + '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', + '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', + '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', + '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', + '0', '0', '0', '0', 'p', '-', '2', ' ', '3', '3', + 0 }; static const uint16_t expected4[] = { '0', 'x', 'e', '.', '0', '0', '0', '0', '0', '0', - '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', - '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', - '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', - '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', - '0', '0', '0', '0', 'p', '-', '3', ' ', '3', '3', - 0 + '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', + '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', + '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', + '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', + '0', '0', '0', '0', 'p', '-', '3', ' ', '3', '3', + 0 }; ASSERT (result != NULL); ASSERT (u16_strcmp (result, expected1) == 0 - || u16_strcmp (result, expected2) == 0 - || u16_strcmp (result, expected3) == 0 - || u16_strcmp (result, expected4) == 0); + || u16_strcmp (result, expected2) == 0 + || u16_strcmp (result, expected3) == 0 + || u16_strcmp (result, expected4) == 0); free (result); } @@ -361,25 +361,25 @@ test_xfunction (uint16_t * (*my_xasprintf) (const char *, ...)) my_xasprintf ("%La %d", 3.1416015625L, 33, 44, 55); static const uint16_t expected1[] = { '0', 'x', '1', '.', '9', '2', '2', 'p', '+', '1', - ' ', '3', '3', 0 + ' ', '3', '3', 0 }; static const uint16_t expected2[] = { '0', 'x', '3', '.', '2', '4', '4', 'p', '+', '0', - ' ', '3', '3', 0 + ' ', '3', '3', 0 }; static const uint16_t expected3[] = { '0', 'x', '6', '.', '4', '8', '8', 'p', '-', '1', - ' ', '3', '3', 0 + ' ', '3', '3', 0 }; static const uint16_t expected4[] = { '0', 'x', 'c', '.', '9', '1', 'p', '-', '2', ' ', - '3', '3', 0 + '3', '3', 0 }; ASSERT (result != NULL); ASSERT (u16_strcmp (result, expected1) == 0 - || u16_strcmp (result, expected2) == 0 - || u16_strcmp (result, expected3) == 0 - || u16_strcmp (result, expected4) == 0); + || u16_strcmp (result, expected2) == 0 + || u16_strcmp (result, expected3) == 0 + || u16_strcmp (result, expected4) == 0); free (result); } @@ -396,9 +396,9 @@ test_xfunction (uint16_t * (*my_xasprintf) (const char *, ...)) { ' ', ' ', ' ', ' ', '0', 'x', 'e', 'p', '-', '3', ' ', '3', '3', 0 }; ASSERT (result != NULL); ASSERT (u16_strcmp (result, expected1) == 0 - || u16_strcmp (result, expected2) == 0 - || u16_strcmp (result, expected3) == 0 - || u16_strcmp (result, expected4) == 0); + || u16_strcmp (result, expected2) == 0 + || u16_strcmp (result, expected3) == 0 + || u16_strcmp (result, expected4) == 0); free (result); } @@ -407,29 +407,29 @@ test_xfunction (uint16_t * (*my_xasprintf) (const char *, ...)) my_xasprintf ("%.10La %d", 1.75L, 33, 44, 55); static const uint16_t expected1[] = { '0', 'x', '1', '.', 'c', '0', '0', '0', '0', '0', - '0', '0', '0', '0', 'p', '+', '0', ' ', '3', '3', - 0 + '0', '0', '0', '0', 'p', '+', '0', ' ', '3', '3', + 0 }; static const uint16_t expected2[] = { '0', 'x', '3', '.', '8', '0', '0', '0', '0', '0', - '0', '0', '0', '0', 'p', '-', '1', ' ', '3', '3', - 0 + '0', '0', '0', '0', 'p', '-', '1', ' ', '3', '3', + 0 }; static const uint16_t expected3[] = { '0', 'x', '7', '.', '0', '0', '0', '0', '0', '0', - '0', '0', '0', '0', 'p', '-', '2', ' ', '3', '3', - 0 + '0', '0', '0', '0', 'p', '-', '2', ' ', '3', '3', + 0 }; static const uint16_t expected4[] = { '0', 'x', 'e', '.', '0', '0', '0', '0', '0', '0', - '0', '0', '0', '0', 'p', '-', '3', ' ', '3', '3', - 0 + '0', '0', '0', '0', 'p', '-', '3', ' ', '3', '3', + 0 }; ASSERT (result != NULL); ASSERT (u16_strcmp (result, expected1) == 0 - || u16_strcmp (result, expected2) == 0 - || u16_strcmp (result, expected3) == 0 - || u16_strcmp (result, expected4) == 0); + || u16_strcmp (result, expected2) == 0 + || u16_strcmp (result, expected3) == 0 + || u16_strcmp (result, expected4) == 0); free (result); } @@ -438,45 +438,45 @@ test_xfunction (uint16_t * (*my_xasprintf) (const char *, ...)) my_xasprintf ("%.50La %d", 1.75L, 33, 44, 55); static const uint16_t expected1[] = { '0', 'x', '1', '.', 'c', '0', '0', '0', '0', '0', - '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', - '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', - '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', - '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', - '0', '0', '0', '0', 'p', '+', '0', ' ', '3', '3', - 0 + '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', + '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', + '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', + '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', + '0', '0', '0', '0', 'p', '+', '0', ' ', '3', '3', + 0 }; static const uint16_t expected2[] = { '0', 'x', '3', '.', '8', '0', '0', '0', '0', '0', - '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', - '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', - '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', - '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', - '0', '0', '0', '0', 'p', '-', '1', ' ', '3', '3', - 0 + '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', + '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', + '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', + '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', + '0', '0', '0', '0', 'p', '-', '1', ' ', '3', '3', + 0 }; static const uint16_t expected3[] = { '0', 'x', '7', '.', '0', '0', '0', '0', '0', '0', - '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', - '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', - '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', - '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', - '0', '0', '0', '0', 'p', '-', '2', ' ', '3', '3', - 0 + '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', + '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', + '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', + '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', + '0', '0', '0', '0', 'p', '-', '2', ' ', '3', '3', + 0 }; static const uint16_t expected4[] = { '0', 'x', 'e', '.', '0', '0', '0', '0', '0', '0', - '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', - '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', - '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', - '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', - '0', '0', '0', '0', 'p', '-', '3', ' ', '3', '3', - 0 + '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', + '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', + '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', + '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', + '0', '0', '0', '0', 'p', '-', '3', ' ', '3', '3', + 0 }; ASSERT (result != NULL); ASSERT (u16_strcmp (result, expected1) == 0 - || u16_strcmp (result, expected2) == 0 - || u16_strcmp (result, expected3) == 0 - || u16_strcmp (result, expected4) == 0); + || u16_strcmp (result, expected2) == 0 + || u16_strcmp (result, expected3) == 0 + || u16_strcmp (result, expected4) == 0); free (result); } @@ -591,15 +591,15 @@ test_xfunction (uint16_t * (*my_xasprintf) (const char *, ...)) my_xasprintf ("%e %d", 12.75, 33, 44, 55); static const uint16_t expected1[] = { '1', '.', '2', '7', '5', '0', '0', '0', 'e', '+', - '0', '1', ' ', '3', '3', 0 + '0', '1', ' ', '3', '3', 0 }; static const uint16_t expected2[] = { '1', '.', '2', '7', '5', '0', '0', '0', 'e', '+', - '0', '0', '1', ' ', '3', '3', 0 + '0', '0', '1', ' ', '3', '3', 0 }; ASSERT (result != NULL); ASSERT (u16_strcmp (result, expected1) == 0 - || u16_strcmp (result, expected2) == 0); + || u16_strcmp (result, expected2) == 0); free (result); } @@ -608,15 +608,15 @@ test_xfunction (uint16_t * (*my_xasprintf) (const char *, ...)) my_xasprintf ("%15e %d", 1.75, 33, 44, 55); static const uint16_t expected1[] = { ' ', ' ', ' ', '1', '.', '7', '5', '0', '0', '0', - '0', 'e', '+', '0', '0', ' ', '3', '3', 0 + '0', 'e', '+', '0', '0', ' ', '3', '3', 0 }; static const uint16_t expected2[] = { ' ', ' ', '1', '.', '7', '5', '0', '0', '0', '0', - 'e', '+', '0', '0', '0', ' ', '3', '3', 0 + 'e', '+', '0', '0', '0', ' ', '3', '3', 0 }; ASSERT (result != NULL); ASSERT (u16_strcmp (result, expected1) == 0 - || u16_strcmp (result, expected2) == 0); + || u16_strcmp (result, expected2) == 0); free (result); } @@ -629,7 +629,7 @@ test_xfunction (uint16_t * (*my_xasprintf) (const char *, ...)) { '1', 'e', '+', '0', '0', '3', ' ', '3', '3', 0 }; ASSERT (result != NULL); ASSERT (u16_strcmp (result, expected1) == 0 - || u16_strcmp (result, expected2) == 0); + || u16_strcmp (result, expected2) == 0); free (result); } @@ -638,7 +638,7 @@ test_xfunction (uint16_t * (*my_xasprintf) (const char *, ...)) my_xasprintf ("%Le %d", 12.75L, 33, 44, 55); static const uint16_t expected[] = { '1', '.', '2', '7', '5', '0', '0', '0', 'e', '+', - '0', '1', ' ', '3', '3', 0 + '0', '1', ' ', '3', '3', 0 }; ASSERT (result != NULL); ASSERT (u16_strcmp (result, expected) == 0); @@ -650,7 +650,7 @@ test_xfunction (uint16_t * (*my_xasprintf) (const char *, ...)) my_xasprintf ("%15Le %d", 1.75L, 33, 44, 55); static const uint16_t expected[] = { ' ', ' ', ' ', '1', '.', '7', '5', '0', '0', '0', - '0', 'e', '+', '0', '0', ' ', '3', '3', 0 + '0', 'e', '+', '0', '0', ' ', '3', '3', 0 }; ASSERT (result != NULL); ASSERT (u16_strcmp (result, expected) == 0); @@ -698,7 +698,7 @@ test_xfunction (uint16_t * (*my_xasprintf) (const char *, ...)) { '1', 'e', '+', '0', '0', '3', ' ', '3', '3', 0 }; ASSERT (result != NULL); ASSERT (u16_strcmp (result, expected1) == 0 - || u16_strcmp (result, expected2) == 0); + || u16_strcmp (result, expected2) == 0); free (result); } @@ -774,47 +774,47 @@ test_xfunction (uint16_t * (*my_xasprintf) (const char *, ...)) static const uint8_t unicode_string[] = "Rafa\305\202 Maszkowski"; /* Rafał Maszkowski */ { uint16_t *result = - my_xasprintf ("%U %d", unicode_string, 33, 44, 55); + my_xasprintf ("%U %d", unicode_string, 33, 44, 55); static const uint16_t expected[] = - { 'R', 'a', 'f', 'a', 0x0142, ' ', 'M', 'a', 's', 'z', - 'k', 'o', 'w', 's', 'k', 'i', ' ', '3', '3', 0 - }; + { 'R', 'a', 'f', 'a', 0x0142, ' ', 'M', 'a', 's', 'z', + 'k', 'o', 'w', 's', 'k', 'i', ' ', '3', '3', 0 + }; ASSERT (result != NULL); ASSERT (u16_strcmp (result, expected) == 0); free (result); } { /* Width. */ uint16_t *result = - my_xasprintf ("%20U %d", unicode_string, 33, 44, 55); + my_xasprintf ("%20U %d", unicode_string, 33, 44, 55); static const uint16_t expected[] = - { ' ', ' ', ' ', ' ', 'R', 'a', 'f', 'a', 0x0142, ' ', - 'M', 'a', 's', 'z', 'k', 'o', 'w', 's', 'k', 'i', - ' ', '3', '3', 0 - }; + { ' ', ' ', ' ', ' ', 'R', 'a', 'f', 'a', 0x0142, ' ', + 'M', 'a', 's', 'z', 'k', 'o', 'w', 's', 'k', 'i', + ' ', '3', '3', 0 + }; ASSERT (result != NULL); ASSERT (u16_strcmp (result, expected) == 0); free (result); } { /* FLAG_LEFT. */ uint16_t *result = - my_xasprintf ("%-20U %d", unicode_string, 33, 44, 55); + my_xasprintf ("%-20U %d", unicode_string, 33, 44, 55); static const uint16_t expected[] = - { 'R', 'a', 'f', 'a', 0x0142, ' ', 'M', 'a', 's', 'z', - 'k', 'o', 'w', 's', 'k', 'i', ' ', ' ', ' ', ' ', - ' ', '3', '3', 0 - }; + { 'R', 'a', 'f', 'a', 0x0142, ' ', 'M', 'a', 's', 'z', + 'k', 'o', 'w', 's', 'k', 'i', ' ', ' ', ' ', ' ', + ' ', '3', '3', 0 + }; ASSERT (result != NULL); ASSERT (u16_strcmp (result, expected) == 0); free (result); } { /* FLAG_ZERO: no effect. */ uint16_t *result = - my_xasprintf ("%020U %d", unicode_string, 33, 44, 55); + my_xasprintf ("%020U %d", unicode_string, 33, 44, 55); static const uint16_t expected[] = - { ' ', ' ', ' ', ' ', 'R', 'a', 'f', 'a', 0x0142, ' ', - 'M', 'a', 's', 'z', 'k', 'o', 'w', 's', 'k', 'i', - ' ', '3', '3', 0 - }; + { ' ', ' ', ' ', ' ', 'R', 'a', 'f', 'a', 0x0142, ' ', + 'M', 'a', 's', 'z', 'k', 'o', 'w', 's', 'k', 'i', + ' ', '3', '3', 0 + }; ASSERT (result != NULL); ASSERT (u16_strcmp (result, expected) == 0); free (result); @@ -824,52 +824,52 @@ test_xfunction (uint16_t * (*my_xasprintf) (const char *, ...)) { static const uint16_t unicode_string[] = /* Rafał Maszkowski */ { - 'R', 'a', 'f', 'a', 0x0142, ' ', 'M', 'a', 's', 'z', 'k', 'o', 'w', - 's', 'k', 'i', 0 + 'R', 'a', 'f', 'a', 0x0142, ' ', 'M', 'a', 's', 'z', 'k', 'o', 'w', + 's', 'k', 'i', 0 }; { uint16_t *result = - my_xasprintf ("%lU %d", unicode_string, 33, 44, 55); + my_xasprintf ("%lU %d", unicode_string, 33, 44, 55); static const uint16_t expected[] = - { 'R', 'a', 'f', 'a', 0x0142, ' ', 'M', 'a', 's', 'z', - 'k', 'o', 'w', 's', 'k', 'i', ' ', '3', '3', 0 - }; + { 'R', 'a', 'f', 'a', 0x0142, ' ', 'M', 'a', 's', 'z', + 'k', 'o', 'w', 's', 'k', 'i', ' ', '3', '3', 0 + }; ASSERT (result != NULL); ASSERT (u16_strcmp (result, expected) == 0); free (result); } { /* Width. */ uint16_t *result = - my_xasprintf ("%20lU %d", unicode_string, 33, 44, 55); + my_xasprintf ("%20lU %d", unicode_string, 33, 44, 55); static const uint16_t expected[] = - { ' ', ' ', ' ', ' ', 'R', 'a', 'f', 'a', 0x0142, ' ', - 'M', 'a', 's', 'z', 'k', 'o', 'w', 's', 'k', 'i', - ' ', '3', '3', 0 - }; + { ' ', ' ', ' ', ' ', 'R', 'a', 'f', 'a', 0x0142, ' ', + 'M', 'a', 's', 'z', 'k', 'o', 'w', 's', 'k', 'i', + ' ', '3', '3', 0 + }; ASSERT (result != NULL); ASSERT (u16_strcmp (result, expected) == 0); free (result); } { /* FLAG_LEFT. */ uint16_t *result = - my_xasprintf ("%-20lU %d", unicode_string, 33, 44, 55); + my_xasprintf ("%-20lU %d", unicode_string, 33, 44, 55); static const uint16_t expected[] = - { 'R', 'a', 'f', 'a', 0x0142, ' ', 'M', 'a', 's', 'z', - 'k', 'o', 'w', 's', 'k', 'i', ' ', ' ', ' ', ' ', - ' ', '3', '3', 0 - }; + { 'R', 'a', 'f', 'a', 0x0142, ' ', 'M', 'a', 's', 'z', + 'k', 'o', 'w', 's', 'k', 'i', ' ', ' ', ' ', ' ', + ' ', '3', '3', 0 + }; ASSERT (result != NULL); ASSERT (u16_strcmp (result, expected) == 0); free (result); } { /* FLAG_ZERO: no effect. */ uint16_t *result = - my_xasprintf ("%020lU %d", unicode_string, 33, 44, 55); + my_xasprintf ("%020lU %d", unicode_string, 33, 44, 55); static const uint16_t expected[] = - { ' ', ' ', ' ', ' ', 'R', 'a', 'f', 'a', 0x0142, ' ', - 'M', 'a', 's', 'z', 'k', 'o', 'w', 's', 'k', 'i', - ' ', '3', '3', 0 - }; + { ' ', ' ', ' ', ' ', 'R', 'a', 'f', 'a', 0x0142, ' ', + 'M', 'a', 's', 'z', 'k', 'o', 'w', 's', 'k', 'i', + ' ', '3', '3', 0 + }; ASSERT (result != NULL); ASSERT (u16_strcmp (result, expected) == 0); free (result); @@ -879,52 +879,52 @@ test_xfunction (uint16_t * (*my_xasprintf) (const char *, ...)) { static const uint32_t unicode_string[] = /* Rafał Maszkowski */ { - 'R', 'a', 'f', 'a', 0x0142, ' ', 'M', 'a', 's', 'z', 'k', 'o', 'w', - 's', 'k', 'i', 0 + 'R', 'a', 'f', 'a', 0x0142, ' ', 'M', 'a', 's', 'z', 'k', 'o', 'w', + 's', 'k', 'i', 0 }; { uint16_t *result = - my_xasprintf ("%llU %d", unicode_string, 33, 44, 55); + my_xasprintf ("%llU %d", unicode_string, 33, 44, 55); static const uint16_t expected[] = - { 'R', 'a', 'f', 'a', 0x0142, ' ', 'M', 'a', 's', 'z', - 'k', 'o', 'w', 's', 'k', 'i', ' ', '3', '3', 0 - }; + { 'R', 'a', 'f', 'a', 0x0142, ' ', 'M', 'a', 's', 'z', + 'k', 'o', 'w', 's', 'k', 'i', ' ', '3', '3', 0 + }; ASSERT (result != NULL); ASSERT (u16_strcmp (result, expected) == 0); free (result); } { /* Width. */ uint16_t *result = - my_xasprintf ("%20llU %d", unicode_string, 33, 44, 55); + my_xasprintf ("%20llU %d", unicode_string, 33, 44, 55); static const uint16_t expected[] = - { ' ', ' ', ' ', ' ', 'R', 'a', 'f', 'a', 0x0142, ' ', - 'M', 'a', 's', 'z', 'k', 'o', 'w', 's', 'k', 'i', - ' ', '3', '3', 0 - }; + { ' ', ' ', ' ', ' ', 'R', 'a', 'f', 'a', 0x0142, ' ', + 'M', 'a', 's', 'z', 'k', 'o', 'w', 's', 'k', 'i', + ' ', '3', '3', 0 + }; ASSERT (result != NULL); ASSERT (u16_strcmp (result, expected) == 0); free (result); } { /* FLAG_LEFT. */ uint16_t *result = - my_xasprintf ("%-20llU %d", unicode_string, 33, 44, 55); + my_xasprintf ("%-20llU %d", unicode_string, 33, 44, 55); static const uint16_t expected[] = - { 'R', 'a', 'f', 'a', 0x0142, ' ', 'M', 'a', 's', 'z', - 'k', 'o', 'w', 's', 'k', 'i', ' ', ' ', ' ', ' ', - ' ', '3', '3', 0 - }; + { 'R', 'a', 'f', 'a', 0x0142, ' ', 'M', 'a', 's', 'z', + 'k', 'o', 'w', 's', 'k', 'i', ' ', ' ', ' ', ' ', + ' ', '3', '3', 0 + }; ASSERT (result != NULL); ASSERT (u16_strcmp (result, expected) == 0); free (result); } { /* FLAG_ZERO: no effect. */ uint16_t *result = - my_xasprintf ("%020llU %d", unicode_string, 33, 44, 55); + my_xasprintf ("%020llU %d", unicode_string, 33, 44, 55); static const uint16_t expected[] = - { ' ', ' ', ' ', ' ', 'R', 'a', 'f', 'a', 0x0142, ' ', - 'M', 'a', 's', 'z', 'k', 'o', 'w', 's', 'k', 'i', - ' ', '3', '3', 0 - }; + { ' ', ' ', ' ', ' ', 'R', 'a', 'f', 'a', 0x0142, ' ', + 'M', 'a', 's', 'z', 'k', 'o', 'w', 's', 'k', 'i', + ' ', '3', '3', 0 + }; ASSERT (result != NULL); ASSERT (u16_strcmp (result, expected) == 0); free (result); diff --git a/tests/unistdio/test-u16-vasnprintf1.c b/tests/unistdio/test-u16-vasnprintf1.c index b236e3f..268b32c 100644 --- a/tests/unistdio/test-u16-vasnprintf1.c +++ b/tests/unistdio/test-u16-vasnprintf1.c @@ -1,5 +1,5 @@ /* Test of u16_vasnprintf() function. - Copyright (C) 2007-2008 Free Software Foundation, Inc. + Copyright (C) 2007-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 @@ -23,25 +23,12 @@ #include <errno.h> #include <stdarg.h> #include <stddef.h> -#include <stdio.h> #include <stdint.h> #include <stdlib.h> #include <string.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" #include "test-u16-asnprintf1.h" #include "test-u16-printf1.h" diff --git a/tests/unistdio/test-u16-vasnprintf2.c b/tests/unistdio/test-u16-vasnprintf2.c index 6f7b7cf..c43967c 100644 --- a/tests/unistdio/test-u16-vasnprintf2.c +++ b/tests/unistdio/test-u16-vasnprintf2.c @@ -1,5 +1,5 @@ /* Test of u16_vasnprintf() function in an ISO-8859-1 locale. - Copyright (C) 2007-2008 Free Software Foundation, Inc. + Copyright (C) 2007-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 @@ -22,25 +22,12 @@ #include <locale.h> #include <stdarg.h> -#include <stdio.h> #include <stdint.h> #include <stdlib.h> #include <string.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 void test_function (uint16_t * (*my_asnprintf) (uint16_t *, size_t *, const char *, ...)) @@ -52,9 +39,9 @@ test_function (uint16_t * (*my_asnprintf) (uint16_t *, size_t *, const char *, . { size_t length; uint16_t *result = - my_asnprintf (NULL, &length, "%s %d", locale_string, 33, 44, 55); + my_asnprintf (NULL, &length, "%s %d", locale_string, 33, 44, 55); static const uint16_t expected[] = - { 0x00c4, 'r', 'g', 'e', 'r', ' ', '3', '3', 0 }; + { 0x00c4, 'r', 'g', 'e', 'r', ' ', '3', '3', 0 }; ASSERT (result != NULL); ASSERT (u16_strcmp (result, expected) == 0); ASSERT (length == u16_strlen (result)); @@ -63,11 +50,11 @@ test_function (uint16_t * (*my_asnprintf) (uint16_t *, size_t *, const char *, . { /* Width. */ size_t length; uint16_t *result = - my_asnprintf (NULL, &length, "%10s %d", locale_string, 33, 44, 55); + my_asnprintf (NULL, &length, "%10s %d", locale_string, 33, 44, 55); static const uint16_t expected[] = - { ' ', ' ', ' ', ' ', ' ', 0x00c4, 'r', 'g', 'e', 'r', - ' ', '3', '3', 0 - }; + { ' ', ' ', ' ', ' ', ' ', 0x00c4, 'r', 'g', 'e', 'r', + ' ', '3', '3', 0 + }; ASSERT (result != NULL); ASSERT (u16_strcmp (result, expected) == 0); ASSERT (length == u16_strlen (result)); @@ -76,11 +63,11 @@ test_function (uint16_t * (*my_asnprintf) (uint16_t *, size_t *, const char *, . { /* FLAG_LEFT. */ size_t length; uint16_t *result = - my_asnprintf (NULL, &length, "%-10s %d", locale_string, 33, 44, 55); + my_asnprintf (NULL, &length, "%-10s %d", locale_string, 33, 44, 55); static const uint16_t expected[] = - { 0x00c4, 'r', 'g', 'e', 'r', ' ', ' ', ' ', ' ', ' ', - ' ', '3', '3', 0 - }; + { 0x00c4, 'r', 'g', 'e', 'r', ' ', ' ', ' ', ' ', ' ', + ' ', '3', '3', 0 + }; ASSERT (result != NULL); ASSERT (u16_strcmp (result, expected) == 0); ASSERT (length == u16_strlen (result)); @@ -89,11 +76,11 @@ test_function (uint16_t * (*my_asnprintf) (uint16_t *, size_t *, const char *, . { /* FLAG_ZERO: no effect. */ size_t length; uint16_t *result = - my_asnprintf (NULL, &length, "%010s %d", locale_string, 33, 44, 55); + my_asnprintf (NULL, &length, "%010s %d", locale_string, 33, 44, 55); static const uint16_t expected[] = - { ' ', ' ', ' ', ' ', ' ', 0x00c4, 'r', 'g', 'e', 'r', - ' ', '3', '3', 0 - }; + { ' ', ' ', ' ', ' ', ' ', 0x00c4, 'r', 'g', 'e', 'r', + ' ', '3', '3', 0 + }; ASSERT (result != NULL); ASSERT (u16_strcmp (result, expected) == 0); ASSERT (length == u16_strlen (result)); diff --git a/tests/unistdio/test-u16-vasnprintf3.c b/tests/unistdio/test-u16-vasnprintf3.c index 1402181..6e741c9 100644 --- a/tests/unistdio/test-u16-vasnprintf3.c +++ b/tests/unistdio/test-u16-vasnprintf3.c @@ -1,5 +1,5 @@ /* Test of u16_vasnprintf() function in an UTF-8 locale. - Copyright (C) 2007-2008 Free Software Foundation, Inc. + Copyright (C) 2007-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 @@ -22,25 +22,12 @@ #include <locale.h> #include <stdarg.h> -#include <stdio.h> #include <stdint.h> #include <stdlib.h> #include <string.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 void test_function (uint16_t * (*my_asnprintf) (uint16_t *, size_t *, const char *, ...)) @@ -52,9 +39,9 @@ test_function (uint16_t * (*my_asnprintf) (uint16_t *, size_t *, const char *, . { size_t length; uint16_t *result = - my_asnprintf (NULL, &length, "%s %d", locale_string, 33, 44, 55); + my_asnprintf (NULL, &length, "%s %d", locale_string, 33, 44, 55); static const uint16_t expected[] = - { 0x00c4, 'r', 'g', 'e', 'r', ' ', '3', '3', 0 }; + { 0x00c4, 'r', 'g', 'e', 'r', ' ', '3', '3', 0 }; ASSERT (result != NULL); ASSERT (u16_strcmp (result, expected) == 0); ASSERT (length == u16_strlen (result)); @@ -63,11 +50,11 @@ test_function (uint16_t * (*my_asnprintf) (uint16_t *, size_t *, const char *, . { /* Width. */ size_t length; uint16_t *result = - my_asnprintf (NULL, &length, "%10s %d", locale_string, 33, 44, 55); + my_asnprintf (NULL, &length, "%10s %d", locale_string, 33, 44, 55); static const uint16_t expected[] = - { ' ', ' ', ' ', ' ', ' ', 0x00c4, 'r', 'g', 'e', 'r', - ' ', '3', '3', 0 - }; + { ' ', ' ', ' ', ' ', ' ', 0x00c4, 'r', 'g', 'e', 'r', + ' ', '3', '3', 0 + }; ASSERT (result != NULL); ASSERT (u16_strcmp (result, expected) == 0); ASSERT (length == u16_strlen (result)); @@ -76,11 +63,11 @@ test_function (uint16_t * (*my_asnprintf) (uint16_t *, size_t *, const char *, . { /* FLAG_LEFT. */ size_t length; uint16_t *result = - my_asnprintf (NULL, &length, "%-10s %d", locale_string, 33, 44, 55); + my_asnprintf (NULL, &length, "%-10s %d", locale_string, 33, 44, 55); static const uint16_t expected[] = - { 0x00c4, 'r', 'g', 'e', 'r', ' ', ' ', ' ', ' ', ' ', - ' ', '3', '3', 0 - }; + { 0x00c4, 'r', 'g', 'e', 'r', ' ', ' ', ' ', ' ', ' ', + ' ', '3', '3', 0 + }; ASSERT (result != NULL); ASSERT (u16_strcmp (result, expected) == 0); ASSERT (length == u16_strlen (result)); @@ -89,11 +76,11 @@ test_function (uint16_t * (*my_asnprintf) (uint16_t *, size_t *, const char *, . { /* FLAG_ZERO: no effect. */ size_t length; uint16_t *result = - my_asnprintf (NULL, &length, "%010s %d", locale_string, 33, 44, 55); + my_asnprintf (NULL, &length, "%010s %d", locale_string, 33, 44, 55); static const uint16_t expected[] = - { ' ', ' ', ' ', ' ', ' ', 0x00c4, 'r', 'g', 'e', 'r', - ' ', '3', '3', 0 - }; + { ' ', ' ', ' ', ' ', ' ', 0x00c4, 'r', 'g', 'e', 'r', + ' ', '3', '3', 0 + }; ASSERT (result != NULL); ASSERT (u16_strcmp (result, expected) == 0); ASSERT (length == u16_strlen (result)); diff --git a/tests/unistdio/test-u16-vasprintf1.c b/tests/unistdio/test-u16-vasprintf1.c index 8b96126..5b60248 100644 --- a/tests/unistdio/test-u16-vasprintf1.c +++ b/tests/unistdio/test-u16-vasprintf1.c @@ -1,5 +1,5 @@ /* Test of u16_vasprintf() function. - Copyright (C) 2007-2008 Free Software Foundation, Inc. + Copyright (C) 2007-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 @@ -23,25 +23,12 @@ #include <errno.h> #include <stdarg.h> #include <stddef.h> -#include <stdio.h> #include <stdint.h> #include <stdlib.h> #include <string.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" #include "test-u16-printf1.h" diff --git a/tests/unistdio/test-u16-vsnprintf1.c b/tests/unistdio/test-u16-vsnprintf1.c index 886e95b..5c2d86c 100644 --- a/tests/unistdio/test-u16-vsnprintf1.c +++ b/tests/unistdio/test-u16-vsnprintf1.c @@ -1,5 +1,5 @@ /* Test of u16_vsnprintf() function. - Copyright (C) 2007-2009 Free Software Foundation, Inc. + Copyright (C) 2007-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 @@ -23,7 +23,6 @@ #include <errno.h> #include <stdarg.h> #include <stddef.h> -#include <stdio.h> #include <stdint.h> #include <stdlib.h> #include <string.h> @@ -31,19 +30,7 @@ #include "unistr.h" #include "xalloc.h" #include "progname.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-printf1.h" diff --git a/tests/unistdio/test-u16-vsprintf1.c b/tests/unistdio/test-u16-vsprintf1.c index e6b6eab..ad42e07 100644 --- a/tests/unistdio/test-u16-vsprintf1.c +++ b/tests/unistdio/test-u16-vsprintf1.c @@ -1,5 +1,5 @@ /* Test of u16_vsprintf() function. - Copyright (C) 2007-2009 Free Software Foundation, Inc. + Copyright (C) 2007-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 @@ -23,7 +23,6 @@ #include <errno.h> #include <stdarg.h> #include <stddef.h> -#include <stdio.h> #include <stdint.h> #include <stdlib.h> #include <string.h> @@ -31,19 +30,7 @@ #include "unistr.h" #include "xalloc.h" #include "progname.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-printf1.h" diff --git a/tests/unistdio/test-u32-asnprintf1.c b/tests/unistdio/test-u32-asnprintf1.c index 252e919..c17fcc6 100644 --- a/tests/unistdio/test-u32-asnprintf1.c +++ b/tests/unistdio/test-u32-asnprintf1.c @@ -1,5 +1,5 @@ /* Test of u32_asnprintf() function. - Copyright (C) 2007-2008 Free Software Foundation, Inc. + Copyright (C) 2007-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 @@ -23,25 +23,12 @@ #include <errno.h> #include <stdarg.h> #include <stddef.h> -#include <stdio.h> #include <stdint.h> #include <stdlib.h> #include <string.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" #include "test-u32-asnprintf1.h" diff --git a/tests/unistdio/test-u32-asnprintf1.h b/tests/unistdio/test-u32-asnprintf1.h index dfaed98..9f73116 100644 --- a/tests/unistdio/test-u32-asnprintf1.h +++ b/tests/unistdio/test-u32-asnprintf1.h @@ -1,5 +1,5 @@ /* Test of u32_[v]asnprintf() function. - Copyright (C) 2007 Free Software Foundation, Inc. + Copyright (C) 2007, 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 @@ -29,7 +29,7 @@ test_function (uint32_t * (*my_asnprintf) (uint32_t *, size_t *, const char *, . size_t length = size; uint32_t *result = my_asnprintf (NULL, &length, "%d", 12345); static const uint32_t expected[] = - { '1', '2', '3', '4', '5', 0 }; + { '1', '2', '3', '4', '5', 0 }; ASSERT (result != NULL); ASSERT (u32_strcmp (result, expected) == 0); ASSERT (length == 5); @@ -39,9 +39,9 @@ test_function (uint32_t * (*my_asnprintf) (uint32_t *, size_t *, const char *, . for (size = 0; size <= 8; size++) { static const uint32_t initializer[] = - { 'D', 'E', 'A', 'D', 'B', 'E', 'E', 'F', 0 }; + { 'D', 'E', 'A', 'D', 'B', 'E', 'E', 'F', 0 }; static const uint32_t expected[] = - { '1', '2', '3', '4', '5', 0 }; + { '1', '2', '3', '4', '5', 0 }; size_t length; uint32_t *result; @@ -52,9 +52,9 @@ test_function (uint32_t * (*my_asnprintf) (uint32_t *, size_t *, const char *, . ASSERT (u32_strcmp (result, expected) == 0); ASSERT (length == 5); if (size < 6) - ASSERT (result != buf); + ASSERT (result != buf); ASSERT (u32_cmp (buf + size, initializer + size, 8 - size) == 0); if (result != buf) - free (result); + free (result); } } diff --git a/tests/unistdio/test-u32-printf1.h b/tests/unistdio/test-u32-printf1.h index 240232f..00b9a60 100644 --- a/tests/unistdio/test-u32-printf1.h +++ b/tests/unistdio/test-u32-printf1.h @@ -1,5 +1,5 @@ /* Test of u32_v[a]s[n]printf() function. - Copyright (C) 2007 Free Software Foundation, Inc. + Copyright (C) 2007, 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 @@ -67,36 +67,36 @@ test_xfunction (uint32_t * (*my_xasprintf) (const char *, ...)) static const uint8_t unicode_string[] = "Hello"; { uint32_t *result = - my_xasprintf ("%U %d", unicode_string, 33, 44, 55); + my_xasprintf ("%U %d", unicode_string, 33, 44, 55); static const uint32_t expected[] = - { 'H', 'e', 'l', 'l', 'o', ' ', '3', '3', 0 }; + { 'H', 'e', 'l', 'l', 'o', ' ', '3', '3', 0 }; ASSERT (result != NULL); ASSERT (u32_strcmp (result, expected) == 0); free (result); } { /* Width. */ uint32_t *result = - my_xasprintf ("%10U %d", unicode_string, 33, 44, 55); + my_xasprintf ("%10U %d", unicode_string, 33, 44, 55); static const uint32_t expected[] = - { ' ', ' ', ' ', ' ', ' ', 'H', 'e', 'l', 'l', 'o', ' ', '3', '3', 0 }; + { ' ', ' ', ' ', ' ', ' ', 'H', 'e', 'l', 'l', 'o', ' ', '3', '3', 0 }; ASSERT (result != NULL); ASSERT (u32_strcmp (result, expected) == 0); free (result); } { /* FLAG_LEFT. */ uint32_t *result = - my_xasprintf ("%-10U %d", unicode_string, 33, 44, 55); + my_xasprintf ("%-10U %d", unicode_string, 33, 44, 55); static const uint32_t expected[] = - { 'H', 'e', 'l', 'l', 'o', ' ', ' ', ' ', ' ', ' ', ' ', '3', '3', 0 }; + { 'H', 'e', 'l', 'l', 'o', ' ', ' ', ' ', ' ', ' ', ' ', '3', '3', 0 }; ASSERT (result != NULL); ASSERT (u32_strcmp (result, expected) == 0); free (result); } { /* FLAG_ZERO: no effect. */ uint32_t *result = - my_xasprintf ("%010U %d", unicode_string, 33, 44, 55); + my_xasprintf ("%010U %d", unicode_string, 33, 44, 55); static const uint32_t expected[] = - { ' ', ' ', ' ', ' ', ' ', 'H', 'e', 'l', 'l', 'o', ' ', '3', '3', 0 }; + { ' ', ' ', ' ', ' ', ' ', 'H', 'e', 'l', 'l', 'o', ' ', '3', '3', 0 }; ASSERT (result != NULL); ASSERT (u32_strcmp (result, expected) == 0); free (result); @@ -107,36 +107,36 @@ test_xfunction (uint32_t * (*my_xasprintf) (const char *, ...)) static const uint16_t unicode_string[] = { 'H', 'e', 'l', 'l', 'o', 0 }; { uint32_t *result = - my_xasprintf ("%lU %d", unicode_string, 33, 44, 55); + my_xasprintf ("%lU %d", unicode_string, 33, 44, 55); static const uint32_t expected[] = - { 'H', 'e', 'l', 'l', 'o', ' ', '3', '3', 0 }; + { 'H', 'e', 'l', 'l', 'o', ' ', '3', '3', 0 }; ASSERT (result != NULL); ASSERT (u32_strcmp (result, expected) == 0); free (result); } { /* Width. */ uint32_t *result = - my_xasprintf ("%10lU %d", unicode_string, 33, 44, 55); + my_xasprintf ("%10lU %d", unicode_string, 33, 44, 55); static const uint32_t expected[] = - { ' ', ' ', ' ', ' ', ' ', 'H', 'e', 'l', 'l', 'o', ' ', '3', '3', 0 }; + { ' ', ' ', ' ', ' ', ' ', 'H', 'e', 'l', 'l', 'o', ' ', '3', '3', 0 }; ASSERT (result != NULL); ASSERT (u32_strcmp (result, expected) == 0); free (result); } { /* FLAG_LEFT. */ uint32_t *result = - my_xasprintf ("%-10lU %d", unicode_string, 33, 44, 55); + my_xasprintf ("%-10lU %d", unicode_string, 33, 44, 55); static const uint32_t expected[] = - { 'H', 'e', 'l', 'l', 'o', ' ', ' ', ' ', ' ', ' ', ' ', '3', '3', 0 }; + { 'H', 'e', 'l', 'l', 'o', ' ', ' ', ' ', ' ', ' ', ' ', '3', '3', 0 }; ASSERT (result != NULL); ASSERT (u32_strcmp (result, expected) == 0); free (result); } { /* FLAG_ZERO: no effect. */ uint32_t *result = - my_xasprintf ("%010lU %d", unicode_string, 33, 44, 55); + my_xasprintf ("%010lU %d", unicode_string, 33, 44, 55); static const uint32_t expected[] = - { ' ', ' ', ' ', ' ', ' ', 'H', 'e', 'l', 'l', 'o', ' ', '3', '3', 0 }; + { ' ', ' ', ' ', ' ', ' ', 'H', 'e', 'l', 'l', 'o', ' ', '3', '3', 0 }; ASSERT (result != NULL); ASSERT (u32_strcmp (result, expected) == 0); free (result); @@ -147,36 +147,36 @@ test_xfunction (uint32_t * (*my_xasprintf) (const char *, ...)) static const uint32_t unicode_string[] = { 'H', 'e', 'l', 'l', 'o', 0 }; { uint32_t *result = - my_xasprintf ("%llU %d", unicode_string, 33, 44, 55); + my_xasprintf ("%llU %d", unicode_string, 33, 44, 55); static const uint32_t expected[] = - { 'H', 'e', 'l', 'l', 'o', ' ', '3', '3', 0 }; + { 'H', 'e', 'l', 'l', 'o', ' ', '3', '3', 0 }; ASSERT (result != NULL); ASSERT (u32_strcmp (result, expected) == 0); free (result); } { /* Width. */ uint32_t *result = - my_xasprintf ("%10llU %d", unicode_string, 33, 44, 55); + my_xasprintf ("%10llU %d", unicode_string, 33, 44, 55); static const uint32_t expected[] = - { ' ', ' ', ' ', ' ', ' ', 'H', 'e', 'l', 'l', 'o', ' ', '3', '3', 0 }; + { ' ', ' ', ' ', ' ', ' ', 'H', 'e', 'l', 'l', 'o', ' ', '3', '3', 0 }; ASSERT (result != NULL); ASSERT (u32_strcmp (result, expected) == 0); free (result); } { /* FLAG_LEFT. */ uint32_t *result = - my_xasprintf ("%-10llU %d", unicode_string, 33, 44, 55); + my_xasprintf ("%-10llU %d", unicode_string, 33, 44, 55); static const uint32_t expected[] = - { 'H', 'e', 'l', 'l', 'o', ' ', ' ', ' ', ' ', ' ', ' ', '3', '3', 0 }; + { 'H', 'e', 'l', 'l', 'o', ' ', ' ', ' ', ' ', ' ', ' ', '3', '3', 0 }; ASSERT (result != NULL); ASSERT (u32_strcmp (result, expected) == 0); free (result); } { /* FLAG_ZERO: no effect. */ uint32_t *result = - my_xasprintf ("%010llU %d", unicode_string, 33, 44, 55); + my_xasprintf ("%010llU %d", unicode_string, 33, 44, 55); static const uint32_t expected[] = - { ' ', ' ', ' ', ' ', ' ', 'H', 'e', 'l', 'l', 'o', ' ', '3', '3', 0 }; + { ' ', ' ', ' ', ' ', ' ', 'H', 'e', 'l', 'l', 'o', ' ', '3', '3', 0 }; ASSERT (result != NULL); ASSERT (u32_strcmp (result, expected) == 0); free (result); @@ -190,8 +190,8 @@ test_xfunction (uint32_t * (*my_xasprintf) (const char *, ...)) my_xasprintf ("Mr. %s %d", "Ronald Reagan", 33, 44, 55); static const uint32_t expected[] = { 'M', 'r', '.', ' ', 'R', 'o', 'n', 'a', 'l', 'd', - ' ', 'R', 'e', 'a', 'g', 'a', 'n', ' ', '3', '3', - 0 + ' ', 'R', 'e', 'a', 'g', 'a', 'n', ' ', '3', '3', + 0 }; ASSERT (result != NULL); ASSERT (u32_strcmp (result, expected) == 0); @@ -203,8 +203,8 @@ test_xfunction (uint32_t * (*my_xasprintf) (const char *, ...)) my_xasprintf ("Mr. %20s %d", "Ronald Reagan", 33, 44, 55); static const uint32_t expected[] = { 'M', 'r', '.', ' ', ' ', ' ', ' ', ' ', ' ', ' ', - ' ', 'R', 'o', 'n', 'a', 'l', 'd', ' ', 'R', 'e', - 'a', 'g', 'a', 'n', ' ', '3', '3', 0 + ' ', 'R', 'o', 'n', 'a', 'l', 'd', ' ', 'R', 'e', + 'a', 'g', 'a', 'n', ' ', '3', '3', 0 }; ASSERT (result != NULL); ASSERT (u32_strcmp (result, expected) == 0); @@ -216,8 +216,8 @@ test_xfunction (uint32_t * (*my_xasprintf) (const char *, ...)) my_xasprintf ("Mr. %-20s %d", "Ronald Reagan", 33, 44, 55); static const uint32_t expected[] = { 'M', 'r', '.', ' ', 'R', 'o', 'n', 'a', 'l', 'd', - ' ', 'R', 'e', 'a', 'g', 'a', 'n', ' ', ' ', ' ', - ' ', ' ', ' ', ' ', ' ', '3', '3', 0 + ' ', 'R', 'e', 'a', 'g', 'a', 'n', ' ', ' ', ' ', + ' ', ' ', ' ', ' ', ' ', '3', '3', 0 }; ASSERT (result != NULL); ASSERT (u32_strcmp (result, expected) == 0); @@ -229,8 +229,8 @@ test_xfunction (uint32_t * (*my_xasprintf) (const char *, ...)) my_xasprintf ("Mr. %020s %d", "Ronald Reagan", 33, 44, 55); static const uint32_t expected[] = { 'M', 'r', '.', ' ', ' ', ' ', ' ', ' ', ' ', ' ', - ' ', 'R', 'o', 'n', 'a', 'l', 'd', ' ', 'R', 'e', - 'a', 'g', 'a', 'n', ' ', '3', '3', 0 + ' ', 'R', 'o', 'n', 'a', 'l', 'd', ' ', 'R', 'e', + 'a', 'g', 'a', 'n', ' ', '3', '3', 0 }; ASSERT (result != NULL); ASSERT (u32_strcmp (result, expected) == 0); @@ -253,9 +253,9 @@ test_xfunction (uint32_t * (*my_xasprintf) (const char *, ...)) { '0', 'x', 'c', '.', '9', '1', 'p', '-', '2', ' ', '3', '3', 0 }; ASSERT (result != NULL); ASSERT (u32_strcmp (result, expected1) == 0 - || u32_strcmp (result, expected2) == 0 - || u32_strcmp (result, expected3) == 0 - || u32_strcmp (result, expected4) == 0); + || u32_strcmp (result, expected2) == 0 + || u32_strcmp (result, expected3) == 0 + || u32_strcmp (result, expected4) == 0); free (result); } @@ -272,9 +272,9 @@ test_xfunction (uint32_t * (*my_xasprintf) (const char *, ...)) { ' ', ' ', ' ', ' ', '0', 'x', 'e', 'p', '-', '3', ' ', '3', '3', 0 }; ASSERT (result != NULL); ASSERT (u32_strcmp (result, expected1) == 0 - || u32_strcmp (result, expected2) == 0 - || u32_strcmp (result, expected3) == 0 - || u32_strcmp (result, expected4) == 0); + || u32_strcmp (result, expected2) == 0 + || u32_strcmp (result, expected3) == 0 + || u32_strcmp (result, expected4) == 0); free (result); } @@ -283,29 +283,29 @@ test_xfunction (uint32_t * (*my_xasprintf) (const char *, ...)) my_xasprintf ("%.10a %d", 1.75, 33, 44, 55); static const uint32_t expected1[] = { '0', 'x', '1', '.', 'c', '0', '0', '0', '0', '0', - '0', '0', '0', '0', 'p', '+', '0', ' ', '3', '3', - 0 + '0', '0', '0', '0', 'p', '+', '0', ' ', '3', '3', + 0 }; static const uint32_t expected2[] = { '0', 'x', '3', '.', '8', '0', '0', '0', '0', '0', - '0', '0', '0', '0', 'p', '-', '1', ' ', '3', '3', - 0 + '0', '0', '0', '0', 'p', '-', '1', ' ', '3', '3', + 0 }; static const uint32_t expected3[] = { '0', 'x', '7', '.', '0', '0', '0', '0', '0', '0', - '0', '0', '0', '0', 'p', '-', '2', ' ', '3', '3', - 0 + '0', '0', '0', '0', 'p', '-', '2', ' ', '3', '3', + 0 }; static const uint32_t expected4[] = { '0', 'x', 'e', '.', '0', '0', '0', '0', '0', '0', - '0', '0', '0', '0', 'p', '-', '3', ' ', '3', '3', - 0 + '0', '0', '0', '0', 'p', '-', '3', ' ', '3', '3', + 0 }; ASSERT (result != NULL); ASSERT (u32_strcmp (result, expected1) == 0 - || u32_strcmp (result, expected2) == 0 - || u32_strcmp (result, expected3) == 0 - || u32_strcmp (result, expected4) == 0); + || u32_strcmp (result, expected2) == 0 + || u32_strcmp (result, expected3) == 0 + || u32_strcmp (result, expected4) == 0); free (result); } @@ -314,45 +314,45 @@ test_xfunction (uint32_t * (*my_xasprintf) (const char *, ...)) my_xasprintf ("%.50a %d", 1.75, 33, 44, 55); static const uint32_t expected1[] = { '0', 'x', '1', '.', 'c', '0', '0', '0', '0', '0', - '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', - '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', - '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', - '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', - '0', '0', '0', '0', 'p', '+', '0', ' ', '3', '3', - 0 + '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', + '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', + '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', + '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', + '0', '0', '0', '0', 'p', '+', '0', ' ', '3', '3', + 0 }; static const uint32_t expected2[] = { '0', 'x', '3', '.', '8', '0', '0', '0', '0', '0', - '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', - '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', - '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', - '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', - '0', '0', '0', '0', 'p', '-', '1', ' ', '3', '3', - 0 + '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', + '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', + '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', + '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', + '0', '0', '0', '0', 'p', '-', '1', ' ', '3', '3', + 0 }; static const uint32_t expected3[] = { '0', 'x', '7', '.', '0', '0', '0', '0', '0', '0', - '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', - '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', - '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', - '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', - '0', '0', '0', '0', 'p', '-', '2', ' ', '3', '3', - 0 + '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', + '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', + '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', + '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', + '0', '0', '0', '0', 'p', '-', '2', ' ', '3', '3', + 0 }; static const uint32_t expected4[] = { '0', 'x', 'e', '.', '0', '0', '0', '0', '0', '0', - '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', - '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', - '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', - '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', - '0', '0', '0', '0', 'p', '-', '3', ' ', '3', '3', - 0 + '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', + '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', + '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', + '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', + '0', '0', '0', '0', 'p', '-', '3', ' ', '3', '3', + 0 }; ASSERT (result != NULL); ASSERT (u32_strcmp (result, expected1) == 0 - || u32_strcmp (result, expected2) == 0 - || u32_strcmp (result, expected3) == 0 - || u32_strcmp (result, expected4) == 0); + || u32_strcmp (result, expected2) == 0 + || u32_strcmp (result, expected3) == 0 + || u32_strcmp (result, expected4) == 0); free (result); } @@ -361,25 +361,25 @@ test_xfunction (uint32_t * (*my_xasprintf) (const char *, ...)) my_xasprintf ("%La %d", 3.1416015625L, 33, 44, 55); static const uint32_t expected1[] = { '0', 'x', '1', '.', '9', '2', '2', 'p', '+', '1', - ' ', '3', '3', 0 + ' ', '3', '3', 0 }; static const uint32_t expected2[] = { '0', 'x', '3', '.', '2', '4', '4', 'p', '+', '0', - ' ', '3', '3', 0 + ' ', '3', '3', 0 }; static const uint32_t expected3[] = { '0', 'x', '6', '.', '4', '8', '8', 'p', '-', '1', - ' ', '3', '3', 0 + ' ', '3', '3', 0 }; static const uint32_t expected4[] = { '0', 'x', 'c', '.', '9', '1', 'p', '-', '2', ' ', - '3', '3', 0 + '3', '3', 0 }; ASSERT (result != NULL); ASSERT (u32_strcmp (result, expected1) == 0 - || u32_strcmp (result, expected2) == 0 - || u32_strcmp (result, expected3) == 0 - || u32_strcmp (result, expected4) == 0); + || u32_strcmp (result, expected2) == 0 + || u32_strcmp (result, expected3) == 0 + || u32_strcmp (result, expected4) == 0); free (result); } @@ -396,9 +396,9 @@ test_xfunction (uint32_t * (*my_xasprintf) (const char *, ...)) { ' ', ' ', ' ', ' ', '0', 'x', 'e', 'p', '-', '3', ' ', '3', '3', 0 }; ASSERT (result != NULL); ASSERT (u32_strcmp (result, expected1) == 0 - || u32_strcmp (result, expected2) == 0 - || u32_strcmp (result, expected3) == 0 - || u32_strcmp (result, expected4) == 0); + || u32_strcmp (result, expected2) == 0 + || u32_strcmp (result, expected3) == 0 + || u32_strcmp (result, expected4) == 0); free (result); } @@ -407,29 +407,29 @@ test_xfunction (uint32_t * (*my_xasprintf) (const char *, ...)) my_xasprintf ("%.10La %d", 1.75L, 33, 44, 55); static const uint32_t expected1[] = { '0', 'x', '1', '.', 'c', '0', '0', '0', '0', '0', - '0', '0', '0', '0', 'p', '+', '0', ' ', '3', '3', - 0 + '0', '0', '0', '0', 'p', '+', '0', ' ', '3', '3', + 0 }; static const uint32_t expected2[] = { '0', 'x', '3', '.', '8', '0', '0', '0', '0', '0', - '0', '0', '0', '0', 'p', '-', '1', ' ', '3', '3', - 0 + '0', '0', '0', '0', 'p', '-', '1', ' ', '3', '3', + 0 }; static const uint32_t expected3[] = { '0', 'x', '7', '.', '0', '0', '0', '0', '0', '0', - '0', '0', '0', '0', 'p', '-', '2', ' ', '3', '3', - 0 + '0', '0', '0', '0', 'p', '-', '2', ' ', '3', '3', + 0 }; static const uint32_t expected4[] = { '0', 'x', 'e', '.', '0', '0', '0', '0', '0', '0', - '0', '0', '0', '0', 'p', '-', '3', ' ', '3', '3', - 0 + '0', '0', '0', '0', 'p', '-', '3', ' ', '3', '3', + 0 }; ASSERT (result != NULL); ASSERT (u32_strcmp (result, expected1) == 0 - || u32_strcmp (result, expected2) == 0 - || u32_strcmp (result, expected3) == 0 - || u32_strcmp (result, expected4) == 0); + || u32_strcmp (result, expected2) == 0 + || u32_strcmp (result, expected3) == 0 + || u32_strcmp (result, expected4) == 0); free (result); } @@ -438,45 +438,45 @@ test_xfunction (uint32_t * (*my_xasprintf) (const char *, ...)) my_xasprintf ("%.50La %d", 1.75L, 33, 44, 55); static const uint32_t expected1[] = { '0', 'x', '1', '.', 'c', '0', '0', '0', '0', '0', - '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', - '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', - '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', - '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', - '0', '0', '0', '0', 'p', '+', '0', ' ', '3', '3', - 0 + '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', + '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', + '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', + '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', + '0', '0', '0', '0', 'p', '+', '0', ' ', '3', '3', + 0 }; static const uint32_t expected2[] = { '0', 'x', '3', '.', '8', '0', '0', '0', '0', '0', - '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', - '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', - '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', - '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', - '0', '0', '0', '0', 'p', '-', '1', ' ', '3', '3', - 0 + '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', + '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', + '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', + '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', + '0', '0', '0', '0', 'p', '-', '1', ' ', '3', '3', + 0 }; static const uint32_t expected3[] = { '0', 'x', '7', '.', '0', '0', '0', '0', '0', '0', - '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', - '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', - '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', - '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', - '0', '0', '0', '0', 'p', '-', '2', ' ', '3', '3', - 0 + '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', + '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', + '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', + '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', + '0', '0', '0', '0', 'p', '-', '2', ' ', '3', '3', + 0 }; static const uint32_t expected4[] = { '0', 'x', 'e', '.', '0', '0', '0', '0', '0', '0', - '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', - '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', - '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', - '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', - '0', '0', '0', '0', 'p', '-', '3', ' ', '3', '3', - 0 + '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', + '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', + '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', + '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', + '0', '0', '0', '0', 'p', '-', '3', ' ', '3', '3', + 0 }; ASSERT (result != NULL); ASSERT (u32_strcmp (result, expected1) == 0 - || u32_strcmp (result, expected2) == 0 - || u32_strcmp (result, expected3) == 0 - || u32_strcmp (result, expected4) == 0); + || u32_strcmp (result, expected2) == 0 + || u32_strcmp (result, expected3) == 0 + || u32_strcmp (result, expected4) == 0); free (result); } @@ -591,15 +591,15 @@ test_xfunction (uint32_t * (*my_xasprintf) (const char *, ...)) my_xasprintf ("%e %d", 12.75, 33, 44, 55); static const uint32_t expected1[] = { '1', '.', '2', '7', '5', '0', '0', '0', 'e', '+', - '0', '1', ' ', '3', '3', 0 + '0', '1', ' ', '3', '3', 0 }; static const uint32_t expected2[] = { '1', '.', '2', '7', '5', '0', '0', '0', 'e', '+', - '0', '0', '1', ' ', '3', '3', 0 + '0', '0', '1', ' ', '3', '3', 0 }; ASSERT (result != NULL); ASSERT (u32_strcmp (result, expected1) == 0 - || u32_strcmp (result, expected2) == 0); + || u32_strcmp (result, expected2) == 0); free (result); } @@ -608,15 +608,15 @@ test_xfunction (uint32_t * (*my_xasprintf) (const char *, ...)) my_xasprintf ("%15e %d", 1.75, 33, 44, 55); static const uint32_t expected1[] = { ' ', ' ', ' ', '1', '.', '7', '5', '0', '0', '0', - '0', 'e', '+', '0', '0', ' ', '3', '3', 0 + '0', 'e', '+', '0', '0', ' ', '3', '3', 0 }; static const uint32_t expected2[] = { ' ', ' ', '1', '.', '7', '5', '0', '0', '0', '0', - 'e', '+', '0', '0', '0', ' ', '3', '3', 0 + 'e', '+', '0', '0', '0', ' ', '3', '3', 0 }; ASSERT (result != NULL); ASSERT (u32_strcmp (result, expected1) == 0 - || u32_strcmp (result, expected2) == 0); + || u32_strcmp (result, expected2) == 0); free (result); } @@ -629,7 +629,7 @@ test_xfunction (uint32_t * (*my_xasprintf) (const char *, ...)) { '1', 'e', '+', '0', '0', '3', ' ', '3', '3', 0 }; ASSERT (result != NULL); ASSERT (u32_strcmp (result, expected1) == 0 - || u32_strcmp (result, expected2) == 0); + || u32_strcmp (result, expected2) == 0); free (result); } @@ -638,7 +638,7 @@ test_xfunction (uint32_t * (*my_xasprintf) (const char *, ...)) my_xasprintf ("%Le %d", 12.75L, 33, 44, 55); static const uint32_t expected[] = { '1', '.', '2', '7', '5', '0', '0', '0', 'e', '+', - '0', '1', ' ', '3', '3', 0 + '0', '1', ' ', '3', '3', 0 }; ASSERT (result != NULL); ASSERT (u32_strcmp (result, expected) == 0); @@ -650,7 +650,7 @@ test_xfunction (uint32_t * (*my_xasprintf) (const char *, ...)) my_xasprintf ("%15Le %d", 1.75L, 33, 44, 55); static const uint32_t expected[] = { ' ', ' ', ' ', '1', '.', '7', '5', '0', '0', '0', - '0', 'e', '+', '0', '0', ' ', '3', '3', 0 + '0', 'e', '+', '0', '0', ' ', '3', '3', 0 }; ASSERT (result != NULL); ASSERT (u32_strcmp (result, expected) == 0); @@ -698,7 +698,7 @@ test_xfunction (uint32_t * (*my_xasprintf) (const char *, ...)) { '1', 'e', '+', '0', '0', '3', ' ', '3', '3', 0 }; ASSERT (result != NULL); ASSERT (u32_strcmp (result, expected1) == 0 - || u32_strcmp (result, expected2) == 0); + || u32_strcmp (result, expected2) == 0); free (result); } @@ -774,47 +774,47 @@ test_xfunction (uint32_t * (*my_xasprintf) (const char *, ...)) static const uint8_t unicode_string[] = "Rafa\305\202 Maszkowski"; /* Rafał Maszkowski */ { uint32_t *result = - my_xasprintf ("%U %d", unicode_string, 33, 44, 55); + my_xasprintf ("%U %d", unicode_string, 33, 44, 55); static const uint32_t expected[] = - { 'R', 'a', 'f', 'a', 0x0142, ' ', 'M', 'a', 's', 'z', - 'k', 'o', 'w', 's', 'k', 'i', ' ', '3', '3', 0 - }; + { 'R', 'a', 'f', 'a', 0x0142, ' ', 'M', 'a', 's', 'z', + 'k', 'o', 'w', 's', 'k', 'i', ' ', '3', '3', 0 + }; ASSERT (result != NULL); ASSERT (u32_strcmp (result, expected) == 0); free (result); } { /* Width. */ uint32_t *result = - my_xasprintf ("%20U %d", unicode_string, 33, 44, 55); + my_xasprintf ("%20U %d", unicode_string, 33, 44, 55); static const uint32_t expected[] = - { ' ', ' ', ' ', ' ', 'R', 'a', 'f', 'a', 0x0142, ' ', - 'M', 'a', 's', 'z', 'k', 'o', 'w', 's', 'k', 'i', - ' ', '3', '3', 0 - }; + { ' ', ' ', ' ', ' ', 'R', 'a', 'f', 'a', 0x0142, ' ', + 'M', 'a', 's', 'z', 'k', 'o', 'w', 's', 'k', 'i', + ' ', '3', '3', 0 + }; ASSERT (result != NULL); ASSERT (u32_strcmp (result, expected) == 0); free (result); } { /* FLAG_LEFT. */ uint32_t *result = - my_xasprintf ("%-20U %d", unicode_string, 33, 44, 55); + my_xasprintf ("%-20U %d", unicode_string, 33, 44, 55); static const uint32_t expected[] = - { 'R', 'a', 'f', 'a', 0x0142, ' ', 'M', 'a', 's', 'z', - 'k', 'o', 'w', 's', 'k', 'i', ' ', ' ', ' ', ' ', - ' ', '3', '3', 0 - }; + { 'R', 'a', 'f', 'a', 0x0142, ' ', 'M', 'a', 's', 'z', + 'k', 'o', 'w', 's', 'k', 'i', ' ', ' ', ' ', ' ', + ' ', '3', '3', 0 + }; ASSERT (result != NULL); ASSERT (u32_strcmp (result, expected) == 0); free (result); } { /* FLAG_ZERO: no effect. */ uint32_t *result = - my_xasprintf ("%020U %d", unicode_string, 33, 44, 55); + my_xasprintf ("%020U %d", unicode_string, 33, 44, 55); static const uint32_t expected[] = - { ' ', ' ', ' ', ' ', 'R', 'a', 'f', 'a', 0x0142, ' ', - 'M', 'a', 's', 'z', 'k', 'o', 'w', 's', 'k', 'i', - ' ', '3', '3', 0 - }; + { ' ', ' ', ' ', ' ', 'R', 'a', 'f', 'a', 0x0142, ' ', + 'M', 'a', 's', 'z', 'k', 'o', 'w', 's', 'k', 'i', + ' ', '3', '3', 0 + }; ASSERT (result != NULL); ASSERT (u32_strcmp (result, expected) == 0); free (result); @@ -824,52 +824,52 @@ test_xfunction (uint32_t * (*my_xasprintf) (const char *, ...)) { static const uint16_t unicode_string[] = /* Rafał Maszkowski */ { - 'R', 'a', 'f', 'a', 0x0142, ' ', 'M', 'a', 's', 'z', 'k', 'o', 'w', - 's', 'k', 'i', 0 + 'R', 'a', 'f', 'a', 0x0142, ' ', 'M', 'a', 's', 'z', 'k', 'o', 'w', + 's', 'k', 'i', 0 }; { uint32_t *result = - my_xasprintf ("%lU %d", unicode_string, 33, 44, 55); + my_xasprintf ("%lU %d", unicode_string, 33, 44, 55); static const uint32_t expected[] = - { 'R', 'a', 'f', 'a', 0x0142, ' ', 'M', 'a', 's', 'z', - 'k', 'o', 'w', 's', 'k', 'i', ' ', '3', '3', 0 - }; + { 'R', 'a', 'f', 'a', 0x0142, ' ', 'M', 'a', 's', 'z', + 'k', 'o', 'w', 's', 'k', 'i', ' ', '3', '3', 0 + }; ASSERT (result != NULL); ASSERT (u32_strcmp (result, expected) == 0); free (result); } { /* Width. */ uint32_t *result = - my_xasprintf ("%20lU %d", unicode_string, 33, 44, 55); + my_xasprintf ("%20lU %d", unicode_string, 33, 44, 55); static const uint32_t expected[] = - { ' ', ' ', ' ', ' ', 'R', 'a', 'f', 'a', 0x0142, ' ', - 'M', 'a', 's', 'z', 'k', 'o', 'w', 's', 'k', 'i', - ' ', '3', '3', 0 - }; + { ' ', ' ', ' ', ' ', 'R', 'a', 'f', 'a', 0x0142, ' ', + 'M', 'a', 's', 'z', 'k', 'o', 'w', 's', 'k', 'i', + ' ', '3', '3', 0 + }; ASSERT (result != NULL); ASSERT (u32_strcmp (result, expected) == 0); free (result); } { /* FLAG_LEFT. */ uint32_t *result = - my_xasprintf ("%-20lU %d", unicode_string, 33, 44, 55); + my_xasprintf ("%-20lU %d", unicode_string, 33, 44, 55); static const uint32_t expected[] = - { 'R', 'a', 'f', 'a', 0x0142, ' ', 'M', 'a', 's', 'z', - 'k', 'o', 'w', 's', 'k', 'i', ' ', ' ', ' ', ' ', - ' ', '3', '3', 0 - }; + { 'R', 'a', 'f', 'a', 0x0142, ' ', 'M', 'a', 's', 'z', + 'k', 'o', 'w', 's', 'k', 'i', ' ', ' ', ' ', ' ', + ' ', '3', '3', 0 + }; ASSERT (result != NULL); ASSERT (u32_strcmp (result, expected) == 0); free (result); } { /* FLAG_ZERO: no effect. */ uint32_t *result = - my_xasprintf ("%020lU %d", unicode_string, 33, 44, 55); + my_xasprintf ("%020lU %d", unicode_string, 33, 44, 55); static const uint32_t expected[] = - { ' ', ' ', ' ', ' ', 'R', 'a', 'f', 'a', 0x0142, ' ', - 'M', 'a', 's', 'z', 'k', 'o', 'w', 's', 'k', 'i', - ' ', '3', '3', 0 - }; + { ' ', ' ', ' ', ' ', 'R', 'a', 'f', 'a', 0x0142, ' ', + 'M', 'a', 's', 'z', 'k', 'o', 'w', 's', 'k', 'i', + ' ', '3', '3', 0 + }; ASSERT (result != NULL); ASSERT (u32_strcmp (result, expected) == 0); free (result); @@ -879,52 +879,52 @@ test_xfunction (uint32_t * (*my_xasprintf) (const char *, ...)) { static const uint32_t unicode_string[] = /* Rafał Maszkowski */ { - 'R', 'a', 'f', 'a', 0x0142, ' ', 'M', 'a', 's', 'z', 'k', 'o', 'w', - 's', 'k', 'i', 0 + 'R', 'a', 'f', 'a', 0x0142, ' ', 'M', 'a', 's', 'z', 'k', 'o', 'w', + 's', 'k', 'i', 0 }; { uint32_t *result = - my_xasprintf ("%llU %d", unicode_string, 33, 44, 55); + my_xasprintf ("%llU %d", unicode_string, 33, 44, 55); static const uint32_t expected[] = - { 'R', 'a', 'f', 'a', 0x0142, ' ', 'M', 'a', 's', 'z', - 'k', 'o', 'w', 's', 'k', 'i', ' ', '3', '3', 0 - }; + { 'R', 'a', 'f', 'a', 0x0142, ' ', 'M', 'a', 's', 'z', + 'k', 'o', 'w', 's', 'k', 'i', ' ', '3', '3', 0 + }; ASSERT (result != NULL); ASSERT (u32_strcmp (result, expected) == 0); free (result); } { /* Width. */ uint32_t *result = - my_xasprintf ("%20llU %d", unicode_string, 33, 44, 55); + my_xasprintf ("%20llU %d", unicode_string, 33, 44, 55); static const uint32_t expected[] = - { ' ', ' ', ' ', ' ', 'R', 'a', 'f', 'a', 0x0142, ' ', - 'M', 'a', 's', 'z', 'k', 'o', 'w', 's', 'k', 'i', - ' ', '3', '3', 0 - }; + { ' ', ' ', ' ', ' ', 'R', 'a', 'f', 'a', 0x0142, ' ', + 'M', 'a', 's', 'z', 'k', 'o', 'w', 's', 'k', 'i', + ' ', '3', '3', 0 + }; ASSERT (result != NULL); ASSERT (u32_strcmp (result, expected) == 0); free (result); } { /* FLAG_LEFT. */ uint32_t *result = - my_xasprintf ("%-20llU %d", unicode_string, 33, 44, 55); + my_xasprintf ("%-20llU %d", unicode_string, 33, 44, 55); static const uint32_t expected[] = - { 'R', 'a', 'f', 'a', 0x0142, ' ', 'M', 'a', 's', 'z', - 'k', 'o', 'w', 's', 'k', 'i', ' ', ' ', ' ', ' ', - ' ', '3', '3', 0 - }; + { 'R', 'a', 'f', 'a', 0x0142, ' ', 'M', 'a', 's', 'z', + 'k', 'o', 'w', 's', 'k', 'i', ' ', ' ', ' ', ' ', + ' ', '3', '3', 0 + }; ASSERT (result != NULL); ASSERT (u32_strcmp (result, expected) == 0); free (result); } { /* FLAG_ZERO: no effect. */ uint32_t *result = - my_xasprintf ("%020llU %d", unicode_string, 33, 44, 55); + my_xasprintf ("%020llU %d", unicode_string, 33, 44, 55); static const uint32_t expected[] = - { ' ', ' ', ' ', ' ', 'R', 'a', 'f', 'a', 0x0142, ' ', - 'M', 'a', 's', 'z', 'k', 'o', 'w', 's', 'k', 'i', - ' ', '3', '3', 0 - }; + { ' ', ' ', ' ', ' ', 'R', 'a', 'f', 'a', 0x0142, ' ', + 'M', 'a', 's', 'z', 'k', 'o', 'w', 's', 'k', 'i', + ' ', '3', '3', 0 + }; ASSERT (result != NULL); ASSERT (u32_strcmp (result, expected) == 0); free (result); diff --git a/tests/unistdio/test-u32-vasnprintf1.c b/tests/unistdio/test-u32-vasnprintf1.c index 959bdab..d2aa879 100644 --- a/tests/unistdio/test-u32-vasnprintf1.c +++ b/tests/unistdio/test-u32-vasnprintf1.c @@ -1,5 +1,5 @@ /* Test of u32_vasnprintf() function. - Copyright (C) 2007-2008 Free Software Foundation, Inc. + Copyright (C) 2007-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 @@ -23,25 +23,12 @@ #include <errno.h> #include <stdarg.h> #include <stddef.h> -#include <stdio.h> #include <stdint.h> #include <stdlib.h> #include <string.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" #include "test-u32-asnprintf1.h" #include "test-u32-printf1.h" diff --git a/tests/unistdio/test-u32-vasnprintf2.c b/tests/unistdio/test-u32-vasnprintf2.c index 9d8ab00..c418e0a 100644 --- a/tests/unistdio/test-u32-vasnprintf2.c +++ b/tests/unistdio/test-u32-vasnprintf2.c @@ -1,5 +1,5 @@ /* Test of u32_vasnprintf() function in an ISO-8859-1 locale. - Copyright (C) 2007-2008 Free Software Foundation, Inc. + Copyright (C) 2007-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 @@ -22,25 +22,12 @@ #include <locale.h> #include <stdarg.h> -#include <stdio.h> #include <stdint.h> #include <stdlib.h> #include <string.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 void test_function (uint32_t * (*my_asnprintf) (uint32_t *, size_t *, const char *, ...)) @@ -52,9 +39,9 @@ test_function (uint32_t * (*my_asnprintf) (uint32_t *, size_t *, const char *, . { size_t length; uint32_t *result = - my_asnprintf (NULL, &length, "%s %d", locale_string, 33, 44, 55); + my_asnprintf (NULL, &length, "%s %d", locale_string, 33, 44, 55); static const uint32_t expected[] = - { 0x00c4, 'r', 'g', 'e', 'r', ' ', '3', '3', 0 }; + { 0x00c4, 'r', 'g', 'e', 'r', ' ', '3', '3', 0 }; ASSERT (result != NULL); ASSERT (u32_strcmp (result, expected) == 0); ASSERT (length == u32_strlen (result)); @@ -63,11 +50,11 @@ test_function (uint32_t * (*my_asnprintf) (uint32_t *, size_t *, const char *, . { /* Width. */ size_t length; uint32_t *result = - my_asnprintf (NULL, &length, "%10s %d", locale_string, 33, 44, 55); + my_asnprintf (NULL, &length, "%10s %d", locale_string, 33, 44, 55); static const uint32_t expected[] = - { ' ', ' ', ' ', ' ', ' ', 0x00c4, 'r', 'g', 'e', 'r', - ' ', '3', '3', 0 - }; + { ' ', ' ', ' ', ' ', ' ', 0x00c4, 'r', 'g', 'e', 'r', + ' ', '3', '3', 0 + }; ASSERT (result != NULL); ASSERT (u32_strcmp (result, expected) == 0); ASSERT (length == u32_strlen (result)); @@ -76,11 +63,11 @@ test_function (uint32_t * (*my_asnprintf) (uint32_t *, size_t *, const char *, . { /* FLAG_LEFT. */ size_t length; uint32_t *result = - my_asnprintf (NULL, &length, "%-10s %d", locale_string, 33, 44, 55); + my_asnprintf (NULL, &length, "%-10s %d", locale_string, 33, 44, 55); static const uint32_t expected[] = - { 0x00c4, 'r', 'g', 'e', 'r', ' ', ' ', ' ', ' ', ' ', - ' ', '3', '3', 0 - }; + { 0x00c4, 'r', 'g', 'e', 'r', ' ', ' ', ' ', ' ', ' ', + ' ', '3', '3', 0 + }; ASSERT (result != NULL); ASSERT (u32_strcmp (result, expected) == 0); ASSERT (length == u32_strlen (result)); @@ -89,11 +76,11 @@ test_function (uint32_t * (*my_asnprintf) (uint32_t *, size_t *, const char *, . { /* FLAG_ZERO: no effect. */ size_t length; uint32_t *result = - my_asnprintf (NULL, &length, "%010s %d", locale_string, 33, 44, 55); + my_asnprintf (NULL, &length, "%010s %d", locale_string, 33, 44, 55); static const uint32_t expected[] = - { ' ', ' ', ' ', ' ', ' ', 0x00c4, 'r', 'g', 'e', 'r', - ' ', '3', '3', 0 - }; + { ' ', ' ', ' ', ' ', ' ', 0x00c4, 'r', 'g', 'e', 'r', + ' ', '3', '3', 0 + }; ASSERT (result != NULL); ASSERT (u32_strcmp (result, expected) == 0); ASSERT (length == u32_strlen (result)); diff --git a/tests/unistdio/test-u32-vasnprintf3.c b/tests/unistdio/test-u32-vasnprintf3.c index 73f7c6c..f4b92d7 100644 --- a/tests/unistdio/test-u32-vasnprintf3.c +++ b/tests/unistdio/test-u32-vasnprintf3.c @@ -1,5 +1,5 @@ /* Test of u32_vasnprintf() function in an UTF-8 locale. - Copyright (C) 2007-2008 Free Software Foundation, Inc. + Copyright (C) 2007-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 @@ -22,25 +22,12 @@ #include <locale.h> #include <stdarg.h> -#include <stdio.h> #include <stdint.h> #include <stdlib.h> #include <string.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 void test_function (uint32_t * (*my_asnprintf) (uint32_t *, size_t *, const char *, ...)) @@ -52,9 +39,9 @@ test_function (uint32_t * (*my_asnprintf) (uint32_t *, size_t *, const char *, . { size_t length; uint32_t *result = - my_asnprintf (NULL, &length, "%s %d", locale_string, 33, 44, 55); + my_asnprintf (NULL, &length, "%s %d", locale_string, 33, 44, 55); static const uint32_t expected[] = - { 0x00c4, 'r', 'g', 'e', 'r', ' ', '3', '3', 0 }; + { 0x00c4, 'r', 'g', 'e', 'r', ' ', '3', '3', 0 }; ASSERT (result != NULL); ASSERT (u32_strcmp (result, expected) == 0); ASSERT (length == u32_strlen (result)); @@ -63,11 +50,11 @@ test_function (uint32_t * (*my_asnprintf) (uint32_t *, size_t *, const char *, . { /* Width. */ size_t length; uint32_t *result = - my_asnprintf (NULL, &length, "%10s %d", locale_string, 33, 44, 55); + my_asnprintf (NULL, &length, "%10s %d", locale_string, 33, 44, 55); static const uint32_t expected[] = - { ' ', ' ', ' ', ' ', ' ', 0x00c4, 'r', 'g', 'e', 'r', - ' ', '3', '3', 0 - }; + { ' ', ' ', ' ', ' ', ' ', 0x00c4, 'r', 'g', 'e', 'r', + ' ', '3', '3', 0 + }; ASSERT (result != NULL); ASSERT (u32_strcmp (result, expected) == 0); ASSERT (length == u32_strlen (result)); @@ -76,11 +63,11 @@ test_function (uint32_t * (*my_asnprintf) (uint32_t *, size_t *, const char *, . { /* FLAG_LEFT. */ size_t length; uint32_t *result = - my_asnprintf (NULL, &length, "%-10s %d", locale_string, 33, 44, 55); + my_asnprintf (NULL, &length, "%-10s %d", locale_string, 33, 44, 55); static const uint32_t expected[] = - { 0x00c4, 'r', 'g', 'e', 'r', ' ', ' ', ' ', ' ', ' ', - ' ', '3', '3', 0 - }; + { 0x00c4, 'r', 'g', 'e', 'r', ' ', ' ', ' ', ' ', ' ', + ' ', '3', '3', 0 + }; ASSERT (result != NULL); ASSERT (u32_strcmp (result, expected) == 0); ASSERT (length == u32_strlen (result)); @@ -89,11 +76,11 @@ test_function (uint32_t * (*my_asnprintf) (uint32_t *, size_t *, const char *, . { /* FLAG_ZERO: no effect. */ size_t length; uint32_t *result = - my_asnprintf (NULL, &length, "%010s %d", locale_string, 33, 44, 55); + my_asnprintf (NULL, &length, "%010s %d", locale_string, 33, 44, 55); static const uint32_t expected[] = - { ' ', ' ', ' ', ' ', ' ', 0x00c4, 'r', 'g', 'e', 'r', - ' ', '3', '3', 0 - }; + { ' ', ' ', ' ', ' ', ' ', 0x00c4, 'r', 'g', 'e', 'r', + ' ', '3', '3', 0 + }; ASSERT (result != NULL); ASSERT (u32_strcmp (result, expected) == 0); ASSERT (length == u32_strlen (result)); diff --git a/tests/unistdio/test-u32-vasprintf1.c b/tests/unistdio/test-u32-vasprintf1.c index 39e68d2..41c3057 100644 --- a/tests/unistdio/test-u32-vasprintf1.c +++ b/tests/unistdio/test-u32-vasprintf1.c @@ -1,5 +1,5 @@ /* Test of u32_vasprintf() function. - Copyright (C) 2007-2008 Free Software Foundation, Inc. + Copyright (C) 2007-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 @@ -23,25 +23,12 @@ #include <errno.h> #include <stdarg.h> #include <stddef.h> -#include <stdio.h> #include <stdint.h> #include <stdlib.h> #include <string.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" #include "test-u32-printf1.h" diff --git a/tests/unistdio/test-u32-vsnprintf1.c b/tests/unistdio/test-u32-vsnprintf1.c index d772708..53317cf 100644 --- a/tests/unistdio/test-u32-vsnprintf1.c +++ b/tests/unistdio/test-u32-vsnprintf1.c @@ -1,5 +1,5 @@ /* Test of u32_vsnprintf() function. - Copyright (C) 2007-2009 Free Software Foundation, Inc. + Copyright (C) 2007-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 @@ -23,7 +23,6 @@ #include <errno.h> #include <stdarg.h> #include <stddef.h> -#include <stdio.h> #include <stdint.h> #include <stdlib.h> #include <string.h> @@ -31,19 +30,7 @@ #include "unistr.h" #include "xalloc.h" #include "progname.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-printf1.h" diff --git a/tests/unistdio/test-u32-vsprintf1.c b/tests/unistdio/test-u32-vsprintf1.c index 8398b27..c9512e8 100644 --- a/tests/unistdio/test-u32-vsprintf1.c +++ b/tests/unistdio/test-u32-vsprintf1.c @@ -1,5 +1,5 @@ /* Test of u32_vsprintf() function. - Copyright (C) 2007-2009 Free Software Foundation, Inc. + Copyright (C) 2007-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 @@ -23,7 +23,6 @@ #include <errno.h> #include <stdarg.h> #include <stddef.h> -#include <stdio.h> #include <stdint.h> #include <stdlib.h> #include <string.h> @@ -31,19 +30,7 @@ #include "unistr.h" #include "xalloc.h" #include "progname.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-printf1.h" diff --git a/tests/unistdio/test-u8-asnprintf1.c b/tests/unistdio/test-u8-asnprintf1.c index 852d76b..983cddf 100644 --- a/tests/unistdio/test-u8-asnprintf1.c +++ b/tests/unistdio/test-u8-asnprintf1.c @@ -1,5 +1,5 @@ /* Test of u8_asnprintf() function. - Copyright (C) 2007-2008 Free Software Foundation, Inc. + Copyright (C) 2007-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 @@ -23,25 +23,12 @@ #include <errno.h> #include <stdarg.h> #include <stddef.h> -#include <stdio.h> #include <stdint.h> #include <stdlib.h> #include <string.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" #include "test-u8-asnprintf1.h" diff --git a/tests/unistdio/test-u8-asnprintf1.h b/tests/unistdio/test-u8-asnprintf1.h index 063f145..d4df3a3 100644 --- a/tests/unistdio/test-u8-asnprintf1.h +++ b/tests/unistdio/test-u8-asnprintf1.h @@ -1,5 +1,5 @@ /* Test of u8_[v]asnprintf() function. - Copyright (C) 2007 Free Software Foundation, Inc. + Copyright (C) 2007, 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 @@ -49,9 +49,9 @@ test_function (uint8_t * (*my_asnprintf) (uint8_t *, size_t *, const char *, ... ASSERT (u8_strcmp (result, expected) == 0); ASSERT (length == 5); if (size < 6) - ASSERT (result != buf); + ASSERT (result != buf); ASSERT (u8_cmp (buf + size, initializer + size, 8 - size) == 0); if (result != buf) - free (result); + free (result); } } diff --git a/tests/unistdio/test-u8-printf1.h b/tests/unistdio/test-u8-printf1.h index 4ac6573..23dc5a6 100644 --- a/tests/unistdio/test-u8-printf1.h +++ b/tests/unistdio/test-u8-printf1.h @@ -1,5 +1,5 @@ /* Test of u8_v[a]s[n]printf() function. - Copyright (C) 2007 Free Software Foundation, Inc. + Copyright (C) 2007, 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 @@ -63,7 +63,7 @@ test_xfunction (uint8_t * (*my_xasprintf) (const char *, ...)) static const uint8_t unicode_string[] = "Hello"; { uint8_t *result = - my_xasprintf ("%U %d", unicode_string, 33, 44, 55); + my_xasprintf ("%U %d", unicode_string, 33, 44, 55); static const uint8_t expected[] = "Hello 33"; ASSERT (result != NULL); ASSERT (u8_strcmp (result, expected) == 0); @@ -71,7 +71,7 @@ test_xfunction (uint8_t * (*my_xasprintf) (const char *, ...)) } { /* Width. */ uint8_t *result = - my_xasprintf ("%10U %d", unicode_string, 33, 44, 55); + my_xasprintf ("%10U %d", unicode_string, 33, 44, 55); static const uint8_t expected[] = " Hello 33"; ASSERT (result != NULL); ASSERT (u8_strcmp (result, expected) == 0); @@ -79,7 +79,7 @@ test_xfunction (uint8_t * (*my_xasprintf) (const char *, ...)) } { /* FLAG_LEFT. */ uint8_t *result = - my_xasprintf ("%-10U %d", unicode_string, 33, 44, 55); + my_xasprintf ("%-10U %d", unicode_string, 33, 44, 55); static const uint8_t expected[] = "Hello 33"; ASSERT (result != NULL); ASSERT (u8_strcmp (result, expected) == 0); @@ -87,7 +87,7 @@ test_xfunction (uint8_t * (*my_xasprintf) (const char *, ...)) } { /* FLAG_ZERO: no effect. */ uint8_t *result = - my_xasprintf ("%010U %d", unicode_string, 33, 44, 55); + my_xasprintf ("%010U %d", unicode_string, 33, 44, 55); static const uint8_t expected[] = " Hello 33"; ASSERT (result != NULL); ASSERT (u8_strcmp (result, expected) == 0); @@ -99,7 +99,7 @@ test_xfunction (uint8_t * (*my_xasprintf) (const char *, ...)) static const uint16_t unicode_string[] = { 'H', 'e', 'l', 'l', 'o', 0 }; { uint8_t *result = - my_xasprintf ("%lU %d", unicode_string, 33, 44, 55); + my_xasprintf ("%lU %d", unicode_string, 33, 44, 55); static const uint8_t expected[] = "Hello 33"; ASSERT (result != NULL); ASSERT (u8_strcmp (result, expected) == 0); @@ -107,7 +107,7 @@ test_xfunction (uint8_t * (*my_xasprintf) (const char *, ...)) } { /* Width. */ uint8_t *result = - my_xasprintf ("%10lU %d", unicode_string, 33, 44, 55); + my_xasprintf ("%10lU %d", unicode_string, 33, 44, 55); static const uint8_t expected[] = " Hello 33"; ASSERT (result != NULL); ASSERT (u8_strcmp (result, expected) == 0); @@ -115,7 +115,7 @@ test_xfunction (uint8_t * (*my_xasprintf) (const char *, ...)) } { /* FLAG_LEFT. */ uint8_t *result = - my_xasprintf ("%-10lU %d", unicode_string, 33, 44, 55); + my_xasprintf ("%-10lU %d", unicode_string, 33, 44, 55); static const uint8_t expected[] = "Hello 33"; ASSERT (result != NULL); ASSERT (u8_strcmp (result, expected) == 0); @@ -123,7 +123,7 @@ test_xfunction (uint8_t * (*my_xasprintf) (const char *, ...)) } { /* FLAG_ZERO: no effect. */ uint8_t *result = - my_xasprintf ("%010lU %d", unicode_string, 33, 44, 55); + my_xasprintf ("%010lU %d", unicode_string, 33, 44, 55); static const uint8_t expected[] = " Hello 33"; ASSERT (result != NULL); ASSERT (u8_strcmp (result, expected) == 0); @@ -135,7 +135,7 @@ test_xfunction (uint8_t * (*my_xasprintf) (const char *, ...)) static const uint32_t unicode_string[] = { 'H', 'e', 'l', 'l', 'o', 0 }; { uint8_t *result = - my_xasprintf ("%llU %d", unicode_string, 33, 44, 55); + my_xasprintf ("%llU %d", unicode_string, 33, 44, 55); static const uint8_t expected[] = "Hello 33"; ASSERT (result != NULL); ASSERT (u8_strcmp (result, expected) == 0); @@ -143,7 +143,7 @@ test_xfunction (uint8_t * (*my_xasprintf) (const char *, ...)) } { /* Width. */ uint8_t *result = - my_xasprintf ("%10llU %d", unicode_string, 33, 44, 55); + my_xasprintf ("%10llU %d", unicode_string, 33, 44, 55); static const uint8_t expected[] = " Hello 33"; ASSERT (result != NULL); ASSERT (u8_strcmp (result, expected) == 0); @@ -151,7 +151,7 @@ test_xfunction (uint8_t * (*my_xasprintf) (const char *, ...)) } { /* FLAG_LEFT. */ uint8_t *result = - my_xasprintf ("%-10llU %d", unicode_string, 33, 44, 55); + my_xasprintf ("%-10llU %d", unicode_string, 33, 44, 55); static const uint8_t expected[] = "Hello 33"; ASSERT (result != NULL); ASSERT (u8_strcmp (result, expected) == 0); @@ -159,7 +159,7 @@ test_xfunction (uint8_t * (*my_xasprintf) (const char *, ...)) } { /* FLAG_ZERO: no effect. */ uint8_t *result = - my_xasprintf ("%010llU %d", unicode_string, 33, 44, 55); + my_xasprintf ("%010llU %d", unicode_string, 33, 44, 55); static const uint8_t expected[] = " Hello 33"; ASSERT (result != NULL); ASSERT (u8_strcmp (result, expected) == 0); @@ -217,9 +217,9 @@ test_xfunction (uint8_t * (*my_xasprintf) (const char *, ...)) static const uint8_t expected4[] = "0xc.91p-2 33"; ASSERT (result != NULL); ASSERT (u8_strcmp (result, expected1) == 0 - || u8_strcmp (result, expected2) == 0 - || u8_strcmp (result, expected3) == 0 - || u8_strcmp (result, expected4) == 0); + || u8_strcmp (result, expected2) == 0 + || u8_strcmp (result, expected3) == 0 + || u8_strcmp (result, expected4) == 0); free (result); } @@ -232,9 +232,9 @@ test_xfunction (uint8_t * (*my_xasprintf) (const char *, ...)) static const uint8_t expected4[] = " 0xep-3 33"; ASSERT (result != NULL); ASSERT (u8_strcmp (result, expected1) == 0 - || u8_strcmp (result, expected2) == 0 - || u8_strcmp (result, expected3) == 0 - || u8_strcmp (result, expected4) == 0); + || u8_strcmp (result, expected2) == 0 + || u8_strcmp (result, expected3) == 0 + || u8_strcmp (result, expected4) == 0); free (result); } @@ -247,9 +247,9 @@ test_xfunction (uint8_t * (*my_xasprintf) (const char *, ...)) static const uint8_t expected4[] = "0xe.0000000000p-3 33"; ASSERT (result != NULL); ASSERT (u8_strcmp (result, expected1) == 0 - || u8_strcmp (result, expected2) == 0 - || u8_strcmp (result, expected3) == 0 - || u8_strcmp (result, expected4) == 0); + || u8_strcmp (result, expected2) == 0 + || u8_strcmp (result, expected3) == 0 + || u8_strcmp (result, expected4) == 0); free (result); } @@ -262,9 +262,9 @@ test_xfunction (uint8_t * (*my_xasprintf) (const char *, ...)) static const uint8_t expected4[] = "0xe.00000000000000000000000000000000000000000000000000p-3 33"; ASSERT (result != NULL); ASSERT (u8_strcmp (result, expected1) == 0 - || u8_strcmp (result, expected2) == 0 - || u8_strcmp (result, expected3) == 0 - || u8_strcmp (result, expected4) == 0); + || u8_strcmp (result, expected2) == 0 + || u8_strcmp (result, expected3) == 0 + || u8_strcmp (result, expected4) == 0); free (result); } @@ -277,9 +277,9 @@ test_xfunction (uint8_t * (*my_xasprintf) (const char *, ...)) static const uint8_t expected4[] = "0xc.91p-2 33"; ASSERT (result != NULL); ASSERT (u8_strcmp (result, expected1) == 0 - || u8_strcmp (result, expected2) == 0 - || u8_strcmp (result, expected3) == 0 - || u8_strcmp (result, expected4) == 0); + || u8_strcmp (result, expected2) == 0 + || u8_strcmp (result, expected3) == 0 + || u8_strcmp (result, expected4) == 0); free (result); } @@ -292,9 +292,9 @@ test_xfunction (uint8_t * (*my_xasprintf) (const char *, ...)) static const uint8_t expected4[] = " 0xep-3 33"; ASSERT (result != NULL); ASSERT (u8_strcmp (result, expected1) == 0 - || u8_strcmp (result, expected2) == 0 - || u8_strcmp (result, expected3) == 0 - || u8_strcmp (result, expected4) == 0); + || u8_strcmp (result, expected2) == 0 + || u8_strcmp (result, expected3) == 0 + || u8_strcmp (result, expected4) == 0); free (result); } @@ -307,9 +307,9 @@ test_xfunction (uint8_t * (*my_xasprintf) (const char *, ...)) static const uint8_t expected4[] = "0xe.0000000000p-3 33"; ASSERT (result != NULL); ASSERT (u8_strcmp (result, expected1) == 0 - || u8_strcmp (result, expected2) == 0 - || u8_strcmp (result, expected3) == 0 - || u8_strcmp (result, expected4) == 0); + || u8_strcmp (result, expected2) == 0 + || u8_strcmp (result, expected3) == 0 + || u8_strcmp (result, expected4) == 0); free (result); } @@ -322,9 +322,9 @@ test_xfunction (uint8_t * (*my_xasprintf) (const char *, ...)) static const uint8_t expected4[] = "0xe.00000000000000000000000000000000000000000000000000p-3 33"; ASSERT (result != NULL); ASSERT (u8_strcmp (result, expected1) == 0 - || u8_strcmp (result, expected2) == 0 - || u8_strcmp (result, expected3) == 0 - || u8_strcmp (result, expected4) == 0); + || u8_strcmp (result, expected2) == 0 + || u8_strcmp (result, expected3) == 0 + || u8_strcmp (result, expected4) == 0); free (result); } @@ -431,7 +431,7 @@ test_xfunction (uint8_t * (*my_xasprintf) (const char *, ...)) static const uint8_t expected2[] = "1.275000e+001 33"; ASSERT (result != NULL); ASSERT (u8_strcmp (result, expected1) == 0 - || u8_strcmp (result, expected2) == 0); + || u8_strcmp (result, expected2) == 0); free (result); } @@ -442,7 +442,7 @@ test_xfunction (uint8_t * (*my_xasprintf) (const char *, ...)) static const uint8_t expected2[] = " 1.750000e+000 33"; ASSERT (result != NULL); ASSERT (u8_strcmp (result, expected1) == 0 - || u8_strcmp (result, expected2) == 0); + || u8_strcmp (result, expected2) == 0); free (result); } @@ -453,7 +453,7 @@ test_xfunction (uint8_t * (*my_xasprintf) (const char *, ...)) static const uint8_t expected2[] = "1e+003 33"; ASSERT (result != NULL); ASSERT (u8_strcmp (result, expected1) == 0 - || u8_strcmp (result, expected2) == 0); + || u8_strcmp (result, expected2) == 0); free (result); } @@ -511,7 +511,7 @@ test_xfunction (uint8_t * (*my_xasprintf) (const char *, ...)) static const uint8_t expected2[] = "1e+003 33"; ASSERT (result != NULL); ASSERT (u8_strcmp (result, expected1) == 0 - || u8_strcmp (result, expected2) == 0); + || u8_strcmp (result, expected2) == 0); free (result); } @@ -582,7 +582,7 @@ test_xfunction (uint8_t * (*my_xasprintf) (const char *, ...)) static const uint8_t unicode_string[] = "Rafa\305\202 Maszkowski"; /* Rafał Maszkowski */ { uint8_t *result = - my_xasprintf ("%U %d", unicode_string, 33, 44, 55); + my_xasprintf ("%U %d", unicode_string, 33, 44, 55); static const uint8_t expected[] = "Rafa\305\202 Maszkowski 33"; ASSERT (result != NULL); ASSERT (u8_strcmp (result, expected) == 0); @@ -590,7 +590,7 @@ test_xfunction (uint8_t * (*my_xasprintf) (const char *, ...)) } { /* Width. */ uint8_t *result = - my_xasprintf ("%20U %d", unicode_string, 33, 44, 55); + my_xasprintf ("%20U %d", unicode_string, 33, 44, 55); static const uint8_t expected[] = " Rafa\305\202 Maszkowski 33"; ASSERT (result != NULL); ASSERT (u8_strcmp (result, expected) == 0); @@ -598,7 +598,7 @@ test_xfunction (uint8_t * (*my_xasprintf) (const char *, ...)) } { /* FLAG_LEFT. */ uint8_t *result = - my_xasprintf ("%-20U %d", unicode_string, 33, 44, 55); + my_xasprintf ("%-20U %d", unicode_string, 33, 44, 55); static const uint8_t expected[] = "Rafa\305\202 Maszkowski 33"; ASSERT (result != NULL); ASSERT (u8_strcmp (result, expected) == 0); @@ -606,7 +606,7 @@ test_xfunction (uint8_t * (*my_xasprintf) (const char *, ...)) } { /* FLAG_ZERO: no effect. */ uint8_t *result = - my_xasprintf ("%020U %d", unicode_string, 33, 44, 55); + my_xasprintf ("%020U %d", unicode_string, 33, 44, 55); static const uint8_t expected[] = " Rafa\305\202 Maszkowski 33"; ASSERT (result != NULL); ASSERT (u8_strcmp (result, expected) == 0); @@ -617,12 +617,12 @@ test_xfunction (uint8_t * (*my_xasprintf) (const char *, ...)) { static const uint16_t unicode_string[] = /* Rafał Maszkowski */ { - 'R', 'a', 'f', 'a', 0x0142, ' ', 'M', 'a', 's', 'z', 'k', 'o', 'w', - 's', 'k', 'i', 0 + 'R', 'a', 'f', 'a', 0x0142, ' ', 'M', 'a', 's', 'z', 'k', 'o', 'w', + 's', 'k', 'i', 0 }; { uint8_t *result = - my_xasprintf ("%lU %d", unicode_string, 33, 44, 55); + my_xasprintf ("%lU %d", unicode_string, 33, 44, 55); static const uint8_t expected[] = "Rafa\305\202 Maszkowski 33"; ASSERT (result != NULL); ASSERT (u8_strcmp (result, expected) == 0); @@ -630,7 +630,7 @@ test_xfunction (uint8_t * (*my_xasprintf) (const char *, ...)) } { /* Width. */ uint8_t *result = - my_xasprintf ("%20lU %d", unicode_string, 33, 44, 55); + my_xasprintf ("%20lU %d", unicode_string, 33, 44, 55); static const uint8_t expected[] = " Rafa\305\202 Maszkowski 33"; ASSERT (result != NULL); ASSERT (u8_strcmp (result, expected) == 0); @@ -638,7 +638,7 @@ test_xfunction (uint8_t * (*my_xasprintf) (const char *, ...)) } { /* FLAG_LEFT. */ uint8_t *result = - my_xasprintf ("%-20lU %d", unicode_string, 33, 44, 55); + my_xasprintf ("%-20lU %d", unicode_string, 33, 44, 55); static const uint8_t expected[] = "Rafa\305\202 Maszkowski 33"; ASSERT (result != NULL); ASSERT (u8_strcmp (result, expected) == 0); @@ -646,7 +646,7 @@ test_xfunction (uint8_t * (*my_xasprintf) (const char *, ...)) } { /* FLAG_ZERO: no effect. */ uint8_t *result = - my_xasprintf ("%020lU %d", unicode_string, 33, 44, 55); + my_xasprintf ("%020lU %d", unicode_string, 33, 44, 55); static const uint8_t expected[] = " Rafa\305\202 Maszkowski 33"; ASSERT (result != NULL); ASSERT (u8_strcmp (result, expected) == 0); @@ -657,12 +657,12 @@ test_xfunction (uint8_t * (*my_xasprintf) (const char *, ...)) { static const uint32_t unicode_string[] = /* Rafał Maszkowski */ { - 'R', 'a', 'f', 'a', 0x0142, ' ', 'M', 'a', 's', 'z', 'k', 'o', 'w', - 's', 'k', 'i', 0 + 'R', 'a', 'f', 'a', 0x0142, ' ', 'M', 'a', 's', 'z', 'k', 'o', 'w', + 's', 'k', 'i', 0 }; { uint8_t *result = - my_xasprintf ("%llU %d", unicode_string, 33, 44, 55); + my_xasprintf ("%llU %d", unicode_string, 33, 44, 55); static const uint8_t expected[] = "Rafa\305\202 Maszkowski 33"; ASSERT (result != NULL); ASSERT (u8_strcmp (result, expected) == 0); @@ -670,7 +670,7 @@ test_xfunction (uint8_t * (*my_xasprintf) (const char *, ...)) } { /* Width. */ uint8_t *result = - my_xasprintf ("%20llU %d", unicode_string, 33, 44, 55); + my_xasprintf ("%20llU %d", unicode_string, 33, 44, 55); static const uint8_t expected[] = " Rafa\305\202 Maszkowski 33"; ASSERT (result != NULL); ASSERT (u8_strcmp (result, expected) == 0); @@ -678,7 +678,7 @@ test_xfunction (uint8_t * (*my_xasprintf) (const char *, ...)) } { /* FLAG_LEFT. */ uint8_t *result = - my_xasprintf ("%-20llU %d", unicode_string, 33, 44, 55); + my_xasprintf ("%-20llU %d", unicode_string, 33, 44, 55); static const uint8_t expected[] = "Rafa\305\202 Maszkowski 33"; ASSERT (result != NULL); ASSERT (u8_strcmp (result, expected) == 0); @@ -686,7 +686,7 @@ test_xfunction (uint8_t * (*my_xasprintf) (const char *, ...)) } { /* FLAG_ZERO: no effect. */ uint8_t *result = - my_xasprintf ("%020llU %d", unicode_string, 33, 44, 55); + my_xasprintf ("%020llU %d", unicode_string, 33, 44, 55); static const uint8_t expected[] = " Rafa\305\202 Maszkowski 33"; ASSERT (result != NULL); ASSERT (u8_strcmp (result, expected) == 0); diff --git a/tests/unistdio/test-u8-vasnprintf1.c b/tests/unistdio/test-u8-vasnprintf1.c index 3329df4..03c73a0 100644 --- a/tests/unistdio/test-u8-vasnprintf1.c +++ b/tests/unistdio/test-u8-vasnprintf1.c @@ -1,5 +1,5 @@ /* Test of u8_vasnprintf() function. - Copyright (C) 2007-2008 Free Software Foundation, Inc. + Copyright (C) 2007-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 @@ -23,25 +23,12 @@ #include <errno.h> #include <stdarg.h> #include <stddef.h> -#include <stdio.h> #include <stdint.h> #include <stdlib.h> #include <string.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" #include "test-u8-asnprintf1.h" #include "test-u8-printf1.h" diff --git a/tests/unistdio/test-u8-vasnprintf2.c b/tests/unistdio/test-u8-vasnprintf2.c index 4283be6..d801ee6 100644 --- a/tests/unistdio/test-u8-vasnprintf2.c +++ b/tests/unistdio/test-u8-vasnprintf2.c @@ -1,5 +1,5 @@ /* Test of u8_vasnprintf() function in an ISO-8859-1 locale. - Copyright (C) 2007-2008 Free Software Foundation, Inc. + Copyright (C) 2007-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 @@ -22,25 +22,12 @@ #include <locale.h> #include <stdarg.h> -#include <stdio.h> #include <stdint.h> #include <stdlib.h> #include <string.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 void test_function (uint8_t * (*my_asnprintf) (uint8_t *, size_t *, const char *, ...)) @@ -52,7 +39,7 @@ test_function (uint8_t * (*my_asnprintf) (uint8_t *, size_t *, const char *, ... { size_t length; uint8_t *result = - my_asnprintf (NULL, &length, "%s %d", locale_string, 33, 44, 55); + my_asnprintf (NULL, &length, "%s %d", locale_string, 33, 44, 55); static const uint8_t expected[] = "\303\204rger 33"; ASSERT (result != NULL); ASSERT (u8_strcmp (result, expected) == 0); @@ -62,7 +49,7 @@ test_function (uint8_t * (*my_asnprintf) (uint8_t *, size_t *, const char *, ... { /* Width. */ size_t length; uint8_t *result = - my_asnprintf (NULL, &length, "%10s %d", locale_string, 33, 44, 55); + my_asnprintf (NULL, &length, "%10s %d", locale_string, 33, 44, 55); static const uint8_t expected[] = " \303\204rger 33"; ASSERT (result != NULL); ASSERT (u8_strcmp (result, expected) == 0); @@ -72,7 +59,7 @@ test_function (uint8_t * (*my_asnprintf) (uint8_t *, size_t *, const char *, ... { /* FLAG_LEFT. */ size_t length; uint8_t *result = - my_asnprintf (NULL, &length, "%-10s %d", locale_string, 33, 44, 55); + my_asnprintf (NULL, &length, "%-10s %d", locale_string, 33, 44, 55); static const uint8_t expected[] = "\303\204rger 33"; ASSERT (result != NULL); ASSERT (u8_strcmp (result, expected) == 0); @@ -82,7 +69,7 @@ test_function (uint8_t * (*my_asnprintf) (uint8_t *, size_t *, const char *, ... { /* FLAG_ZERO: no effect. */ size_t length; uint8_t *result = - my_asnprintf (NULL, &length, "%010s %d", locale_string, 33, 44, 55); + my_asnprintf (NULL, &length, "%010s %d", locale_string, 33, 44, 55); static const uint8_t expected[] = " \303\204rger 33"; ASSERT (result != NULL); ASSERT (u8_strcmp (result, expected) == 0); diff --git a/tests/unistdio/test-u8-vasnprintf3.c b/tests/unistdio/test-u8-vasnprintf3.c index fc645bc..752c4c5 100644 --- a/tests/unistdio/test-u8-vasnprintf3.c +++ b/tests/unistdio/test-u8-vasnprintf3.c @@ -1,5 +1,5 @@ /* Test of u8_vasnprintf() function in an UTF-8 locale. - Copyright (C) 2007-2008 Free Software Foundation, Inc. + Copyright (C) 2007-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 @@ -22,25 +22,12 @@ #include <locale.h> #include <stdarg.h> -#include <stdio.h> #include <stdint.h> #include <stdlib.h> #include <string.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 void test_function (uint8_t * (*my_asnprintf) (uint8_t *, size_t *, const char *, ...)) @@ -52,7 +39,7 @@ test_function (uint8_t * (*my_asnprintf) (uint8_t *, size_t *, const char *, ... { size_t length; uint8_t *result = - my_asnprintf (NULL, &length, "%s %d", locale_string, 33, 44, 55); + my_asnprintf (NULL, &length, "%s %d", locale_string, 33, 44, 55); static const uint8_t expected[] = "\303\204rger 33"; ASSERT (result != NULL); ASSERT (u8_strcmp (result, expected) == 0); @@ -62,7 +49,7 @@ test_function (uint8_t * (*my_asnprintf) (uint8_t *, size_t *, const char *, ... { /* Width. */ size_t length; uint8_t *result = - my_asnprintf (NULL, &length, "%10s %d", locale_string, 33, 44, 55); + my_asnprintf (NULL, &length, "%10s %d", locale_string, 33, 44, 55); static const uint8_t expected[] = " \303\204rger 33"; ASSERT (result != NULL); ASSERT (u8_strcmp (result, expected) == 0); @@ -72,7 +59,7 @@ test_function (uint8_t * (*my_asnprintf) (uint8_t *, size_t *, const char *, ... { /* FLAG_LEFT. */ size_t length; uint8_t *result = - my_asnprintf (NULL, &length, "%-10s %d", locale_string, 33, 44, 55); + my_asnprintf (NULL, &length, "%-10s %d", locale_string, 33, 44, 55); static const uint8_t expected[] = "\303\204rger 33"; ASSERT (result != NULL); ASSERT (u8_strcmp (result, expected) == 0); @@ -82,7 +69,7 @@ test_function (uint8_t * (*my_asnprintf) (uint8_t *, size_t *, const char *, ... { /* FLAG_ZERO: no effect. */ size_t length; uint8_t *result = - my_asnprintf (NULL, &length, "%010s %d", locale_string, 33, 44, 55); + my_asnprintf (NULL, &length, "%010s %d", locale_string, 33, 44, 55); static const uint8_t expected[] = " \303\204rger 33"; ASSERT (result != NULL); ASSERT (u8_strcmp (result, expected) == 0); diff --git a/tests/unistdio/test-u8-vasprintf1.c b/tests/unistdio/test-u8-vasprintf1.c index 8a2caae..4076db5 100644 --- a/tests/unistdio/test-u8-vasprintf1.c +++ b/tests/unistdio/test-u8-vasprintf1.c @@ -1,5 +1,5 @@ /* Test of u8_vasprintf() function. - Copyright (C) 2007-2008 Free Software Foundation, Inc. + Copyright (C) 2007-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 @@ -23,25 +23,12 @@ #include <errno.h> #include <stdarg.h> #include <stddef.h> -#include <stdio.h> #include <stdint.h> #include <stdlib.h> #include <string.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" #include "test-u8-printf1.h" diff --git a/tests/unistdio/test-u8-vsnprintf1.c b/tests/unistdio/test-u8-vsnprintf1.c index 6dd7439..1ae5876 100644 --- a/tests/unistdio/test-u8-vsnprintf1.c +++ b/tests/unistdio/test-u8-vsnprintf1.c @@ -1,5 +1,5 @@ /* Test of u8_vsnprintf() function. - Copyright (C) 2007-2009 Free Software Foundation, Inc. + Copyright (C) 2007-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 @@ -23,7 +23,6 @@ #include <errno.h> #include <stdarg.h> #include <stddef.h> -#include <stdio.h> #include <stdint.h> #include <stdlib.h> #include <string.h> @@ -31,19 +30,7 @@ #include "unistr.h" #include "xalloc.h" #include "progname.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-printf1.h" diff --git a/tests/unistdio/test-u8-vsprintf1.c b/tests/unistdio/test-u8-vsprintf1.c index 9559df0..3e13fec 100644 --- a/tests/unistdio/test-u8-vsprintf1.c +++ b/tests/unistdio/test-u8-vsprintf1.c @@ -1,5 +1,5 @@ /* Test of u8_vsprintf() function. - Copyright (C) 2007-2009 Free Software Foundation, Inc. + Copyright (C) 2007-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 @@ -23,7 +23,6 @@ #include <errno.h> #include <stdarg.h> #include <stddef.h> -#include <stdio.h> #include <stdint.h> #include <stdlib.h> #include <string.h> @@ -31,19 +30,7 @@ #include "unistr.h" #include "xalloc.h" #include "progname.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-printf1.h" diff --git a/tests/unistdio/test-ulc-asnprintf1.c b/tests/unistdio/test-ulc-asnprintf1.c index 591ae26..b9bd2ef 100644 --- a/tests/unistdio/test-ulc-asnprintf1.c +++ b/tests/unistdio/test-ulc-asnprintf1.c @@ -1,5 +1,5 @@ /* Test of ulc_asnprintf() function. - Copyright (C) 2007-2008 Free Software Foundation, Inc. + Copyright (C) 2007-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 @@ -22,23 +22,11 @@ #include <stdarg.h> #include <stddef.h> -#include <stdio.h> #include <stdint.h> #include <stdlib.h> #include <string.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-ulc-asnprintf1.h" diff --git a/tests/unistdio/test-ulc-asnprintf1.h b/tests/unistdio/test-ulc-asnprintf1.h index 285a406..eb68248 100644 --- a/tests/unistdio/test-ulc-asnprintf1.h +++ b/tests/unistdio/test-ulc-asnprintf1.h @@ -1,5 +1,5 @@ /* Test of ulc_[v]asnprintf() functions. - Copyright (C) 2007 Free Software Foundation, Inc. + Copyright (C) 2007, 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 @@ -46,9 +46,9 @@ test_function (char * (*my_asnprintf) (char *, size_t *, const char *, ...)) ASSERT (strcmp (result, "12345") == 0); ASSERT (length == 5); if (size < 6) - ASSERT (result != buf); + ASSERT (result != buf); ASSERT (memcmp (buf + size, "DEADBEEF" + size, 8 - size) == 0); if (result != buf) - free (result); + free (result); } } diff --git a/tests/unistdio/test-ulc-printf1.h b/tests/unistdio/test-ulc-printf1.h index 77516d6..12149a4 100644 --- a/tests/unistdio/test-ulc-printf1.h +++ b/tests/unistdio/test-ulc-printf1.h @@ -1,5 +1,5 @@ /* Test of ulc_v[a]s[n]printf() functions. - Copyright (C) 2007 Free Software Foundation, Inc. + Copyright (C) 2007, 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 @@ -59,28 +59,28 @@ test_xfunction (char * (*my_xasprintf) (const char *, ...)) static const uint8_t unicode_string[] = "Hello"; { char *result = - my_xasprintf ("%U %d", unicode_string, 33, 44, 55); + my_xasprintf ("%U %d", unicode_string, 33, 44, 55); ASSERT (result != NULL); ASSERT (strcmp (result, "Hello 33") == 0); free (result); } { /* Width. */ char *result = - my_xasprintf ("%10U %d", unicode_string, 33, 44, 55); + my_xasprintf ("%10U %d", unicode_string, 33, 44, 55); ASSERT (result != NULL); ASSERT (strcmp (result, " Hello 33") == 0); free (result); } { /* FLAG_LEFT. */ char *result = - my_xasprintf ("%-10U %d", unicode_string, 33, 44, 55); + my_xasprintf ("%-10U %d", unicode_string, 33, 44, 55); ASSERT (result != NULL); ASSERT (strcmp (result, "Hello 33") == 0); free (result); } { /* FLAG_ZERO: no effect. */ char *result = - my_xasprintf ("%010U %d", unicode_string, 33, 44, 55); + my_xasprintf ("%010U %d", unicode_string, 33, 44, 55); ASSERT (result != NULL); ASSERT (strcmp (result, " Hello 33") == 0); free (result); @@ -91,28 +91,28 @@ test_xfunction (char * (*my_xasprintf) (const char *, ...)) static const uint16_t unicode_string[] = { 'H', 'e', 'l', 'l', 'o', 0 }; { char *result = - my_xasprintf ("%lU %d", unicode_string, 33, 44, 55); + my_xasprintf ("%lU %d", unicode_string, 33, 44, 55); ASSERT (result != NULL); ASSERT (strcmp (result, "Hello 33") == 0); free (result); } { /* Width. */ char *result = - my_xasprintf ("%10lU %d", unicode_string, 33, 44, 55); + my_xasprintf ("%10lU %d", unicode_string, 33, 44, 55); ASSERT (result != NULL); ASSERT (strcmp (result, " Hello 33") == 0); free (result); } { /* FLAG_LEFT. */ char *result = - my_xasprintf ("%-10lU %d", unicode_string, 33, 44, 55); + my_xasprintf ("%-10lU %d", unicode_string, 33, 44, 55); ASSERT (result != NULL); ASSERT (strcmp (result, "Hello 33") == 0); free (result); } { /* FLAG_ZERO: no effect. */ char *result = - my_xasprintf ("%010lU %d", unicode_string, 33, 44, 55); + my_xasprintf ("%010lU %d", unicode_string, 33, 44, 55); ASSERT (result != NULL); ASSERT (strcmp (result, " Hello 33") == 0); free (result); @@ -123,28 +123,28 @@ test_xfunction (char * (*my_xasprintf) (const char *, ...)) static const uint32_t unicode_string[] = { 'H', 'e', 'l', 'l', 'o', 0 }; { char *result = - my_xasprintf ("%llU %d", unicode_string, 33, 44, 55); + my_xasprintf ("%llU %d", unicode_string, 33, 44, 55); ASSERT (result != NULL); ASSERT (strcmp (result, "Hello 33") == 0); free (result); } { /* Width. */ char *result = - my_xasprintf ("%10llU %d", unicode_string, 33, 44, 55); + my_xasprintf ("%10llU %d", unicode_string, 33, 44, 55); ASSERT (result != NULL); ASSERT (strcmp (result, " Hello 33") == 0); free (result); } { /* FLAG_LEFT. */ char *result = - my_xasprintf ("%-10llU %d", unicode_string, 33, 44, 55); + my_xasprintf ("%-10llU %d", unicode_string, 33, 44, 55); ASSERT (result != NULL); ASSERT (strcmp (result, "Hello 33") == 0); free (result); } { /* FLAG_ZERO: no effect. */ char *result = - my_xasprintf ("%010llU %d", unicode_string, 33, 44, 55); + my_xasprintf ("%010llU %d", unicode_string, 33, 44, 55); ASSERT (result != NULL); ASSERT (strcmp (result, " Hello 33") == 0); free (result); @@ -193,9 +193,9 @@ test_xfunction (char * (*my_xasprintf) (const char *, ...)) my_xasprintf ("%a %d", 3.1416015625, 33, 44, 55); ASSERT (result != NULL); ASSERT (strcmp (result, "0x1.922p+1 33") == 0 - || strcmp (result, "0x3.244p+0 33") == 0 - || strcmp (result, "0x6.488p-1 33") == 0 - || strcmp (result, "0xc.91p-2 33") == 0); + || strcmp (result, "0x3.244p+0 33") == 0 + || strcmp (result, "0x6.488p-1 33") == 0 + || strcmp (result, "0xc.91p-2 33") == 0); free (result); } @@ -204,9 +204,9 @@ test_xfunction (char * (*my_xasprintf) (const char *, ...)) my_xasprintf ("%10a %d", 1.75, 33, 44, 55); ASSERT (result != NULL); ASSERT (strcmp (result, " 0x1.cp+0 33") == 0 - || strcmp (result, " 0x3.8p-1 33") == 0 - || strcmp (result, " 0x7p-2 33") == 0 - || strcmp (result, " 0xep-3 33") == 0); + || strcmp (result, " 0x3.8p-1 33") == 0 + || strcmp (result, " 0x7p-2 33") == 0 + || strcmp (result, " 0xep-3 33") == 0); free (result); } @@ -215,9 +215,9 @@ test_xfunction (char * (*my_xasprintf) (const char *, ...)) my_xasprintf ("%.10a %d", 1.75, 33, 44, 55); ASSERT (result != NULL); ASSERT (strcmp (result, "0x1.c000000000p+0 33") == 0 - || strcmp (result, "0x3.8000000000p-1 33") == 0 - || strcmp (result, "0x7.0000000000p-2 33") == 0 - || strcmp (result, "0xe.0000000000p-3 33") == 0); + || strcmp (result, "0x3.8000000000p-1 33") == 0 + || strcmp (result, "0x7.0000000000p-2 33") == 0 + || strcmp (result, "0xe.0000000000p-3 33") == 0); free (result); } @@ -226,9 +226,9 @@ test_xfunction (char * (*my_xasprintf) (const char *, ...)) my_xasprintf ("%.50a %d", 1.75, 33, 44, 55); ASSERT (result != NULL); ASSERT (strcmp (result, "0x1.c0000000000000000000000000000000000000000000000000p+0 33") == 0 - || strcmp (result, "0x3.80000000000000000000000000000000000000000000000000p-1 33") == 0 - || strcmp (result, "0x7.00000000000000000000000000000000000000000000000000p-2 33") == 0 - || strcmp (result, "0xe.00000000000000000000000000000000000000000000000000p-3 33") == 0); + || strcmp (result, "0x3.80000000000000000000000000000000000000000000000000p-1 33") == 0 + || strcmp (result, "0x7.00000000000000000000000000000000000000000000000000p-2 33") == 0 + || strcmp (result, "0xe.00000000000000000000000000000000000000000000000000p-3 33") == 0); free (result); } @@ -237,9 +237,9 @@ test_xfunction (char * (*my_xasprintf) (const char *, ...)) my_xasprintf ("%La %d", 3.1416015625L, 33, 44, 55); ASSERT (result != NULL); ASSERT (strcmp (result, "0x1.922p+1 33") == 0 - || strcmp (result, "0x3.244p+0 33") == 0 - || strcmp (result, "0x6.488p-1 33") == 0 - || strcmp (result, "0xc.91p-2 33") == 0); + || strcmp (result, "0x3.244p+0 33") == 0 + || strcmp (result, "0x6.488p-1 33") == 0 + || strcmp (result, "0xc.91p-2 33") == 0); free (result); } @@ -248,9 +248,9 @@ test_xfunction (char * (*my_xasprintf) (const char *, ...)) my_xasprintf ("%10La %d", 1.75L, 33, 44, 55); ASSERT (result != NULL); ASSERT (strcmp (result, " 0x1.cp+0 33") == 0 - || strcmp (result, " 0x3.8p-1 33") == 0 - || strcmp (result, " 0x7p-2 33") == 0 - || strcmp (result, " 0xep-3 33") == 0); + || strcmp (result, " 0x3.8p-1 33") == 0 + || strcmp (result, " 0x7p-2 33") == 0 + || strcmp (result, " 0xep-3 33") == 0); free (result); } @@ -259,9 +259,9 @@ test_xfunction (char * (*my_xasprintf) (const char *, ...)) my_xasprintf ("%.10La %d", 1.75L, 33, 44, 55); ASSERT (result != NULL); ASSERT (strcmp (result, "0x1.c000000000p+0 33") == 0 - || strcmp (result, "0x3.8000000000p-1 33") == 0 - || strcmp (result, "0x7.0000000000p-2 33") == 0 - || strcmp (result, "0xe.0000000000p-3 33") == 0); + || strcmp (result, "0x3.8000000000p-1 33") == 0 + || strcmp (result, "0x7.0000000000p-2 33") == 0 + || strcmp (result, "0xe.0000000000p-3 33") == 0); free (result); } @@ -270,9 +270,9 @@ test_xfunction (char * (*my_xasprintf) (const char *, ...)) my_xasprintf ("%.50La %d", 1.75L, 33, 44, 55); ASSERT (result != NULL); ASSERT (strcmp (result, "0x1.c0000000000000000000000000000000000000000000000000p+0 33") == 0 - || strcmp (result, "0x3.80000000000000000000000000000000000000000000000000p-1 33") == 0 - || strcmp (result, "0x7.00000000000000000000000000000000000000000000000000p-2 33") == 0 - || strcmp (result, "0xe.00000000000000000000000000000000000000000000000000p-3 33") == 0); + || strcmp (result, "0x3.80000000000000000000000000000000000000000000000000p-1 33") == 0 + || strcmp (result, "0x7.00000000000000000000000000000000000000000000000000p-2 33") == 0 + || strcmp (result, "0xe.00000000000000000000000000000000000000000000000000p-3 33") == 0); free (result); } @@ -367,7 +367,7 @@ test_xfunction (char * (*my_xasprintf) (const char *, ...)) my_xasprintf ("%e %d", 12.75, 33, 44, 55); ASSERT (result != NULL); ASSERT (strcmp (result, "1.275000e+01 33") == 0 - || strcmp (result, "1.275000e+001 33") == 0); + || strcmp (result, "1.275000e+001 33") == 0); free (result); } @@ -376,7 +376,7 @@ test_xfunction (char * (*my_xasprintf) (const char *, ...)) my_xasprintf ("%15e %d", 1.75, 33, 44, 55); ASSERT (result != NULL); ASSERT (strcmp (result, " 1.750000e+00 33") == 0 - || strcmp (result, " 1.750000e+000 33") == 0); + || strcmp (result, " 1.750000e+000 33") == 0); free (result); } @@ -385,7 +385,7 @@ test_xfunction (char * (*my_xasprintf) (const char *, ...)) my_xasprintf ("%.e %d", 1234.0, 33, 44, 55); ASSERT (result != NULL); ASSERT (strcmp (result, "1e+03 33") == 0 - || strcmp (result, "1e+003 33") == 0); + || strcmp (result, "1e+003 33") == 0); free (result); } @@ -436,7 +436,7 @@ test_xfunction (char * (*my_xasprintf) (const char *, ...)) my_xasprintf ("%.g %d", 1234.0, 33, 44, 55); ASSERT (result != NULL); ASSERT (strcmp (result, "1e+03 33") == 0 - || strcmp (result, "1e+003 33") == 0); + || strcmp (result, "1e+003 33") == 0); free (result); } diff --git a/tests/unistdio/test-ulc-vasnprintf1.c b/tests/unistdio/test-ulc-vasnprintf1.c index e2f8be6..fa4a2c9 100644 --- a/tests/unistdio/test-ulc-vasnprintf1.c +++ b/tests/unistdio/test-ulc-vasnprintf1.c @@ -1,5 +1,5 @@ /* Test of ulc_vasnprintf() function. - Copyright (C) 2007-2008 Free Software Foundation, Inc. + Copyright (C) 2007-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 @@ -22,23 +22,11 @@ #include <stdarg.h> #include <stddef.h> -#include <stdio.h> #include <stdint.h> #include <stdlib.h> #include <string.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-ulc-asnprintf1.h" #include "test-ulc-printf1.h" diff --git a/tests/unistdio/test-ulc-vasnprintf2.c b/tests/unistdio/test-ulc-vasnprintf2.c index 9022975..d61c1cf 100644 --- a/tests/unistdio/test-ulc-vasnprintf2.c +++ b/tests/unistdio/test-ulc-vasnprintf2.c @@ -1,5 +1,5 @@ /* Test of ulc_vasnprintf() function in an ISO-8859-1 locale. - Copyright (C) 2007-2008 Free Software Foundation, Inc. + Copyright (C) 2007-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 @@ -22,23 +22,11 @@ #include <locale.h> #include <stdarg.h> -#include <stdio.h> #include <stdint.h> #include <stdlib.h> #include <string.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 void test_function (char * (*my_asnprintf) (char *, size_t *, const char *, ...)) @@ -50,40 +38,40 @@ test_function (char * (*my_asnprintf) (char *, size_t *, const char *, ...)) { size_t length; char *result = - my_asnprintf (NULL, &length, "%U %d", unicode_string, 33, 44, 55); + my_asnprintf (NULL, &length, "%U %d", unicode_string, 33, 44, 55); ASSERT (result != NULL); ASSERT (strcmp (result, "Rafa? Maszkowski 33") == 0 - || strcmp (result, "Rafal Maszkowski 33") == 0); + || strcmp (result, "Rafal Maszkowski 33") == 0); ASSERT (length == strlen (result)); free (result); } { /* Width. */ size_t length; char *result = - my_asnprintf (NULL, &length, "%20U %d", unicode_string, 33, 44, 55); + my_asnprintf (NULL, &length, "%20U %d", unicode_string, 33, 44, 55); ASSERT (result != NULL); ASSERT (strcmp (result, " Rafa? Maszkowski 33") == 0 - || strcmp (result, " Rafal Maszkowski 33") == 0); + || strcmp (result, " Rafal Maszkowski 33") == 0); ASSERT (length == strlen (result)); free (result); } { /* FLAG_LEFT. */ size_t length; char *result = - my_asnprintf (NULL, &length, "%-20U %d", unicode_string, 33, 44, 55); + my_asnprintf (NULL, &length, "%-20U %d", unicode_string, 33, 44, 55); ASSERT (result != NULL); ASSERT (strcmp (result, "Rafa? Maszkowski 33") == 0 - || strcmp (result, "Rafal Maszkowski 33") == 0); + || strcmp (result, "Rafal Maszkowski 33") == 0); ASSERT (length == strlen (result)); free (result); } { /* FLAG_ZERO: no effect. */ size_t length; char *result = - my_asnprintf (NULL, &length, "%020U %d", unicode_string, 33, 44, 55); + my_asnprintf (NULL, &length, "%020U %d", unicode_string, 33, 44, 55); ASSERT (result != NULL); ASSERT (strcmp (result, " Rafa? Maszkowski 33") == 0 - || strcmp (result, " Rafal Maszkowski 33") == 0); + || strcmp (result, " Rafal Maszkowski 33") == 0); ASSERT (length == strlen (result)); free (result); } @@ -92,46 +80,46 @@ test_function (char * (*my_asnprintf) (char *, size_t *, const char *, ...)) { static const uint16_t unicode_string[] = /* Rafał Maszkowski */ { - 'R', 'a', 'f', 'a', 0x0142, ' ', 'M', 'a', 's', 'z', 'k', 'o', 'w', - 's', 'k', 'i', 0 + 'R', 'a', 'f', 'a', 0x0142, ' ', 'M', 'a', 's', 'z', 'k', 'o', 'w', + 's', 'k', 'i', 0 }; { size_t length; char *result = - my_asnprintf (NULL, &length, "%lU %d", unicode_string, 33, 44, 55); + my_asnprintf (NULL, &length, "%lU %d", unicode_string, 33, 44, 55); ASSERT (result != NULL); ASSERT (strcmp (result, "Rafa? Maszkowski 33") == 0 - || strcmp (result, "Rafal Maszkowski 33") == 0); + || strcmp (result, "Rafal Maszkowski 33") == 0); ASSERT (length == strlen (result)); free (result); } { /* Width. */ size_t length; char *result = - my_asnprintf (NULL, &length, "%20lU %d", unicode_string, 33, 44, 55); + my_asnprintf (NULL, &length, "%20lU %d", unicode_string, 33, 44, 55); ASSERT (result != NULL); ASSERT (strcmp (result, " Rafa? Maszkowski 33") == 0 - || strcmp (result, " Rafal Maszkowski 33") == 0); + || strcmp (result, " Rafal Maszkowski 33") == 0); ASSERT (length == strlen (result)); free (result); } { /* FLAG_LEFT. */ size_t length; char *result = - my_asnprintf (NULL, &length, "%-20lU %d", unicode_string, 33, 44, 55); + my_asnprintf (NULL, &length, "%-20lU %d", unicode_string, 33, 44, 55); ASSERT (result != NULL); ASSERT (strcmp (result, "Rafa? Maszkowski 33") == 0 - || strcmp (result, "Rafal Maszkowski 33") == 0); + || strcmp (result, "Rafal Maszkowski 33") == 0); ASSERT (length == strlen (result)); free (result); } { /* FLAG_ZERO: no effect. */ size_t length; char *result = - my_asnprintf (NULL, &length, "%020lU %d", unicode_string, 33, 44, 55); + my_asnprintf (NULL, &length, "%020lU %d", unicode_string, 33, 44, 55); ASSERT (result != NULL); ASSERT (strcmp (result, " Rafa? Maszkowski 33") == 0 - || strcmp (result, " Rafal Maszkowski 33") == 0); + || strcmp (result, " Rafal Maszkowski 33") == 0); ASSERT (length == strlen (result)); free (result); } @@ -140,46 +128,46 @@ test_function (char * (*my_asnprintf) (char *, size_t *, const char *, ...)) { static const uint32_t unicode_string[] = /* Rafał Maszkowski */ { - 'R', 'a', 'f', 'a', 0x0142, ' ', 'M', 'a', 's', 'z', 'k', 'o', 'w', - 's', 'k', 'i', 0 + 'R', 'a', 'f', 'a', 0x0142, ' ', 'M', 'a', 's', 'z', 'k', 'o', 'w', + 's', 'k', 'i', 0 }; { size_t length; char *result = - my_asnprintf (NULL, &length, "%llU %d", unicode_string, 33, 44, 55); + my_asnprintf (NULL, &length, "%llU %d", unicode_string, 33, 44, 55); ASSERT (result != NULL); ASSERT (strcmp (result, "Rafa? Maszkowski 33") == 0 - || strcmp (result, "Rafal Maszkowski 33") == 0); + || strcmp (result, "Rafal Maszkowski 33") == 0); ASSERT (length == strlen (result)); free (result); } { /* Width. */ size_t length; char *result = - my_asnprintf (NULL, &length, "%20llU %d", unicode_string, 33, 44, 55); + my_asnprintf (NULL, &length, "%20llU %d", unicode_string, 33, 44, 55); ASSERT (result != NULL); ASSERT (strcmp (result, " Rafa? Maszkowski 33") == 0 - || strcmp (result, " Rafal Maszkowski 33") == 0); + || strcmp (result, " Rafal Maszkowski 33") == 0); ASSERT (length == strlen (result)); free (result); } { /* FLAG_LEFT. */ size_t length; char *result = - my_asnprintf (NULL, &length, "%-20llU %d", unicode_string, 33, 44, 55); + my_asnprintf (NULL, &length, "%-20llU %d", unicode_string, 33, 44, 55); ASSERT (result != NULL); ASSERT (strcmp (result, "Rafa? Maszkowski 33") == 0 - || strcmp (result, "Rafal Maszkowski 33") == 0); + || strcmp (result, "Rafal Maszkowski 33") == 0); ASSERT (length == strlen (result)); free (result); } { /* FLAG_ZERO: no effect. */ size_t length; char *result = - my_asnprintf (NULL, &length, "%020llU %d", unicode_string, 33, 44, 55); + my_asnprintf (NULL, &length, "%020llU %d", unicode_string, 33, 44, 55); ASSERT (result != NULL); ASSERT (strcmp (result, " Rafa? Maszkowski 33") == 0 - || strcmp (result, " Rafal Maszkowski 33") == 0); + || strcmp (result, " Rafal Maszkowski 33") == 0); ASSERT (length == strlen (result)); free (result); } @@ -192,7 +180,7 @@ test_function (char * (*my_asnprintf) (char *, size_t *, const char *, ...)) { size_t length; char *result = - my_asnprintf (NULL, &length, "%s %d", locale_string, 33, 44, 55); + my_asnprintf (NULL, &length, "%s %d", locale_string, 33, 44, 55); ASSERT (result != NULL); ASSERT (strcmp (result, "\304rger 33") == 0); ASSERT (length == strlen (result)); @@ -201,7 +189,7 @@ test_function (char * (*my_asnprintf) (char *, size_t *, const char *, ...)) { /* Width. */ size_t length; char *result = - my_asnprintf (NULL, &length, "%10s %d", locale_string, 33, 44, 55); + my_asnprintf (NULL, &length, "%10s %d", locale_string, 33, 44, 55); ASSERT (result != NULL); ASSERT (strcmp (result, " \304rger 33") == 0); ASSERT (length == strlen (result)); @@ -210,7 +198,7 @@ test_function (char * (*my_asnprintf) (char *, size_t *, const char *, ...)) { /* FLAG_LEFT. */ size_t length; char *result = - my_asnprintf (NULL, &length, "%-10s %d", locale_string, 33, 44, 55); + my_asnprintf (NULL, &length, "%-10s %d", locale_string, 33, 44, 55); ASSERT (result != NULL); ASSERT (strcmp (result, "\304rger 33") == 0); ASSERT (length == strlen (result)); @@ -219,7 +207,7 @@ test_function (char * (*my_asnprintf) (char *, size_t *, const char *, ...)) { /* FLAG_ZERO: no effect. */ size_t length; char *result = - my_asnprintf (NULL, &length, "%010s %d", locale_string, 33, 44, 55); + my_asnprintf (NULL, &length, "%010s %d", locale_string, 33, 44, 55); ASSERT (result != NULL); ASSERT (strcmp (result, " \304rger 33") == 0); ASSERT (length == strlen (result)); diff --git a/tests/unistdio/test-ulc-vasnprintf3.c b/tests/unistdio/test-ulc-vasnprintf3.c index 1fbd925..5a3cd0d 100644 --- a/tests/unistdio/test-ulc-vasnprintf3.c +++ b/tests/unistdio/test-ulc-vasnprintf3.c @@ -1,5 +1,5 @@ /* Test of ulc_vasnprintf() function in an UTF-8 locale. - Copyright (C) 2007-2008 Free Software Foundation, Inc. + Copyright (C) 2007-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 @@ -22,23 +22,11 @@ #include <locale.h> #include <stdarg.h> -#include <stdio.h> #include <stdint.h> #include <stdlib.h> #include <string.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 void test_function (char * (*my_asnprintf) (char *, size_t *, const char *, ...)) @@ -50,7 +38,7 @@ test_function (char * (*my_asnprintf) (char *, size_t *, const char *, ...)) { size_t length; char *result = - my_asnprintf (NULL, &length, "%U %d", unicode_string, 33, 44, 55); + my_asnprintf (NULL, &length, "%U %d", unicode_string, 33, 44, 55); ASSERT (result != NULL); ASSERT (strcmp (result, "Rafa\305\202 Maszkowski 33") == 0); ASSERT (length == strlen (result)); @@ -59,7 +47,7 @@ test_function (char * (*my_asnprintf) (char *, size_t *, const char *, ...)) { /* Width. */ size_t length; char *result = - my_asnprintf (NULL, &length, "%20U %d", unicode_string, 33, 44, 55); + my_asnprintf (NULL, &length, "%20U %d", unicode_string, 33, 44, 55); ASSERT (result != NULL); ASSERT (strcmp (result, " Rafa\305\202 Maszkowski 33") == 0); ASSERT (length == strlen (result)); @@ -68,7 +56,7 @@ test_function (char * (*my_asnprintf) (char *, size_t *, const char *, ...)) { /* FLAG_LEFT. */ size_t length; char *result = - my_asnprintf (NULL, &length, "%-20U %d", unicode_string, 33, 44, 55); + my_asnprintf (NULL, &length, "%-20U %d", unicode_string, 33, 44, 55); ASSERT (result != NULL); ASSERT (strcmp (result, "Rafa\305\202 Maszkowski 33") == 0); ASSERT (length == strlen (result)); @@ -77,7 +65,7 @@ test_function (char * (*my_asnprintf) (char *, size_t *, const char *, ...)) { /* FLAG_ZERO: no effect. */ size_t length; char *result = - my_asnprintf (NULL, &length, "%020U %d", unicode_string, 33, 44, 55); + my_asnprintf (NULL, &length, "%020U %d", unicode_string, 33, 44, 55); ASSERT (result != NULL); ASSERT (strcmp (result, " Rafa\305\202 Maszkowski 33") == 0); ASSERT (length == strlen (result)); @@ -88,13 +76,13 @@ test_function (char * (*my_asnprintf) (char *, size_t *, const char *, ...)) { static const uint16_t unicode_string[] = /* Rafał Maszkowski */ { - 'R', 'a', 'f', 'a', 0x0142, ' ', 'M', 'a', 's', 'z', 'k', 'o', 'w', - 's', 'k', 'i', 0 + 'R', 'a', 'f', 'a', 0x0142, ' ', 'M', 'a', 's', 'z', 'k', 'o', 'w', + 's', 'k', 'i', 0 }; { size_t length; char *result = - my_asnprintf (NULL, &length, "%lU %d", unicode_string, 33, 44, 55); + my_asnprintf (NULL, &length, "%lU %d", unicode_string, 33, 44, 55); ASSERT (result != NULL); ASSERT (strcmp (result, "Rafa\305\202 Maszkowski 33") == 0); ASSERT (length == strlen (result)); @@ -103,7 +91,7 @@ test_function (char * (*my_asnprintf) (char *, size_t *, const char *, ...)) { /* Width. */ size_t length; char *result = - my_asnprintf (NULL, &length, "%20lU %d", unicode_string, 33, 44, 55); + my_asnprintf (NULL, &length, "%20lU %d", unicode_string, 33, 44, 55); ASSERT (result != NULL); ASSERT (strcmp (result, " Rafa\305\202 Maszkowski 33") == 0); ASSERT (length == strlen (result)); @@ -112,7 +100,7 @@ test_function (char * (*my_asnprintf) (char *, size_t *, const char *, ...)) { /* FLAG_LEFT. */ size_t length; char *result = - my_asnprintf (NULL, &length, "%-20lU %d", unicode_string, 33, 44, 55); + my_asnprintf (NULL, &length, "%-20lU %d", unicode_string, 33, 44, 55); ASSERT (result != NULL); ASSERT (strcmp (result, "Rafa\305\202 Maszkowski 33") == 0); ASSERT (length == strlen (result)); @@ -121,7 +109,7 @@ test_function (char * (*my_asnprintf) (char *, size_t *, const char *, ...)) { /* FLAG_ZERO: no effect. */ size_t length; char *result = - my_asnprintf (NULL, &length, "%020lU %d", unicode_string, 33, 44, 55); + my_asnprintf (NULL, &length, "%020lU %d", unicode_string, 33, 44, 55); ASSERT (result != NULL); ASSERT (strcmp (result, " Rafa\305\202 Maszkowski 33") == 0); ASSERT (length == strlen (result)); @@ -132,13 +120,13 @@ test_function (char * (*my_asnprintf) (char *, size_t *, const char *, ...)) { static const uint32_t unicode_string[] = /* Rafał Maszkowski */ { - 'R', 'a', 'f', 'a', 0x0142, ' ', 'M', 'a', 's', 'z', 'k', 'o', 'w', - 's', 'k', 'i', 0 + 'R', 'a', 'f', 'a', 0x0142, ' ', 'M', 'a', 's', 'z', 'k', 'o', 'w', + 's', 'k', 'i', 0 }; { size_t length; char *result = - my_asnprintf (NULL, &length, "%llU %d", unicode_string, 33, 44, 55); + my_asnprintf (NULL, &length, "%llU %d", unicode_string, 33, 44, 55); ASSERT (result != NULL); ASSERT (strcmp (result, "Rafa\305\202 Maszkowski 33") == 0); ASSERT (length == strlen (result)); @@ -147,7 +135,7 @@ test_function (char * (*my_asnprintf) (char *, size_t *, const char *, ...)) { /* Width. */ size_t length; char *result = - my_asnprintf (NULL, &length, "%20llU %d", unicode_string, 33, 44, 55); + my_asnprintf (NULL, &length, "%20llU %d", unicode_string, 33, 44, 55); ASSERT (result != NULL); ASSERT (strcmp (result, " Rafa\305\202 Maszkowski 33") == 0); ASSERT (length == strlen (result)); @@ -156,7 +144,7 @@ test_function (char * (*my_asnprintf) (char *, size_t *, const char *, ...)) { /* FLAG_LEFT. */ size_t length; char *result = - my_asnprintf (NULL, &length, "%-20llU %d", unicode_string, 33, 44, 55); + my_asnprintf (NULL, &length, "%-20llU %d", unicode_string, 33, 44, 55); ASSERT (result != NULL); ASSERT (strcmp (result, "Rafa\305\202 Maszkowski 33") == 0); ASSERT (length == strlen (result)); @@ -165,7 +153,7 @@ test_function (char * (*my_asnprintf) (char *, size_t *, const char *, ...)) { /* FLAG_ZERO: no effect. */ size_t length; char *result = - my_asnprintf (NULL, &length, "%020llU %d", unicode_string, 33, 44, 55); + my_asnprintf (NULL, &length, "%020llU %d", unicode_string, 33, 44, 55); ASSERT (result != NULL); ASSERT (strcmp (result, " Rafa\305\202 Maszkowski 33") == 0); ASSERT (length == strlen (result)); @@ -180,7 +168,7 @@ test_function (char * (*my_asnprintf) (char *, size_t *, const char *, ...)) { size_t length; char *result = - my_asnprintf (NULL, &length, "%s %d", locale_string, 33, 44, 55); + my_asnprintf (NULL, &length, "%s %d", locale_string, 33, 44, 55); ASSERT (result != NULL); ASSERT (strcmp (result, "\303\204rger 33") == 0); ASSERT (length == strlen (result)); @@ -189,7 +177,7 @@ test_function (char * (*my_asnprintf) (char *, size_t *, const char *, ...)) { /* Width. */ size_t length; char *result = - my_asnprintf (NULL, &length, "%10s %d", locale_string, 33, 44, 55); + my_asnprintf (NULL, &length, "%10s %d", locale_string, 33, 44, 55); ASSERT (result != NULL); ASSERT (strcmp (result, " \303\204rger 33") == 0); ASSERT (length == strlen (result)); @@ -198,7 +186,7 @@ test_function (char * (*my_asnprintf) (char *, size_t *, const char *, ...)) { /* FLAG_LEFT. */ size_t length; char *result = - my_asnprintf (NULL, &length, "%-10s %d", locale_string, 33, 44, 55); + my_asnprintf (NULL, &length, "%-10s %d", locale_string, 33, 44, 55); ASSERT (result != NULL); ASSERT (strcmp (result, "\303\204rger 33") == 0); ASSERT (length == strlen (result)); @@ -207,7 +195,7 @@ test_function (char * (*my_asnprintf) (char *, size_t *, const char *, ...)) { /* FLAG_ZERO: no effect. */ size_t length; char *result = - my_asnprintf (NULL, &length, "%010s %d", locale_string, 33, 44, 55); + my_asnprintf (NULL, &length, "%010s %d", locale_string, 33, 44, 55); ASSERT (result != NULL); ASSERT (strcmp (result, " \303\204rger 33") == 0); ASSERT (length == strlen (result)); diff --git a/tests/unistdio/test-ulc-vasprintf1.c b/tests/unistdio/test-ulc-vasprintf1.c index d8ed67c..0db01c9 100644 --- a/tests/unistdio/test-ulc-vasprintf1.c +++ b/tests/unistdio/test-ulc-vasprintf1.c @@ -1,5 +1,5 @@ /* Test of ulc_vasprintf() function. - Copyright (C) 2007-2008 Free Software Foundation, Inc. + Copyright (C) 2007-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 @@ -22,23 +22,11 @@ #include <stdarg.h> #include <stddef.h> -#include <stdio.h> #include <stdint.h> #include <stdlib.h> #include <string.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-ulc-printf1.h" diff --git a/tests/unistdio/test-ulc-vsnprintf1.c b/tests/unistdio/test-ulc-vsnprintf1.c index 7701c21..7b6de1c 100644 --- a/tests/unistdio/test-ulc-vsnprintf1.c +++ b/tests/unistdio/test-ulc-vsnprintf1.c @@ -1,5 +1,5 @@ /* Test of ulc_vsnprintf() function. - Copyright (C) 2007-2009 Free Software Foundation, Inc. + Copyright (C) 2007-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 @@ -22,26 +22,13 @@ #include <stdarg.h> #include <stddef.h> -#include <stdio.h> #include <stdint.h> #include <stdlib.h> #include <string.h> #include "xalloc.h" #include "progname.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-ulc-printf1.h" diff --git a/tests/unistdio/test-ulc-vsprintf1.c b/tests/unistdio/test-ulc-vsprintf1.c index 76b85b2..51ea024 100644 --- a/tests/unistdio/test-ulc-vsprintf1.c +++ b/tests/unistdio/test-ulc-vsprintf1.c @@ -1,5 +1,5 @@ /* Test of ulc_vsprintf() function. - Copyright (C) 2007-2009 Free Software Foundation, Inc. + Copyright (C) 2007-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 @@ -22,26 +22,13 @@ #include <stdarg.h> #include <stddef.h> -#include <stdio.h> #include <stdint.h> #include <stdlib.h> #include <string.h> #include "xalloc.h" #include "progname.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-ulc-printf1.h" |