/* Test of u8_v[a]s[n]printf() function.
- Copyright (C) 2007 Free Software Foundation, Inc.
+ Copyright (C) 2007, 2009-2013 Free Software Foundation, Inc.
- This program is free software; you can redistribute it and/or modify
+ 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
- the Free Software Foundation; either version 2, or (at your option)
- any later version.
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software Foundation,
- Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* Written by Bruno Haible <bruno@clisp.org>, 2007. */
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);
}
{ /* 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);
}
{ /* 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);
}
{ /* 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);
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);
}
{ /* 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);
}
{ /* 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);
}
{ /* 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);
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);
}
{ /* 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);
}
{ /* 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);
}
{ /* 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);
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);
}
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);
}
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);
}
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);
}
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);
}
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);
}
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);
}
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);
}
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);
}
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);
}
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);
}
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);
}
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);
}
{ /* 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);
}
{ /* 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);
}
{ /* 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);
{
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);
}
{ /* 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);
}
{ /* 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);
}
{ /* 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);
{
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);
}
{ /* 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);
}
{ /* 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);
}
{ /* 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);