1/* This file is part of the GNU C Library.
2 Copyright (C) 2012-2022 Free Software Foundation, Inc.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
9 The GNU C Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <https://www.gnu.org/licenses/>. */
17
18#include <array_length.h>
19#include <wchar.h>
20
21/* Prototype for our test function. */
22static int do_test (void);
23
24static int
25do_test (void)
26{
27#ifndef NO_LONG_DOUBLE
28 int result = 0;
29 const long double x = 24.5;
30 wchar_t a[16];
31 swprintf (s: a, array_length (a), format: L"%La\n", x);
32 wchar_t A[16];
33 swprintf (s: A, array_length (a), format: L"%LA\n", x);
34
35 /* Here wprintf can return four valid variants. We must accept all
36 of them. */
37 result |= (wmemcmp (s1: a, s2: L"0xc.4p+1", n: 8) == 0
38 && wmemcmp (s1: A, s2: L"0XC.4P+1", n: 8) == 0);
39 result |= (wmemcmp (s1: a, s2: L"0x3.1p+3", n: 8) == 0
40 && wmemcmp (s1: A, s2: L"0X3.1P+3", n: 8) == 0);
41 result |= (wmemcmp (s1: a, s2: L"0x6.2p+2", n: 8) == 0
42 && wmemcmp (s1: A, s2: L"0X6.2P+2", n: 8) == 0);
43 result |= (wmemcmp (s1: a, s2: L"0x1.88p+4", n: 8) == 0
44 && wmemcmp (s1: A, s2: L"0X1.88P+4", n: 8) == 0);
45
46 return result != 1;
47#else
48 return 0;
49#endif
50}
51
52#define TEST_FUNCTION do_test ()
53#include "../test-skeleton.c"
54

source code of glibc/stdio-common/tst-long-dbl-fphex.c