File: bug16.c

package info (click to toggle)
glibc 2.31-13%2Bdeb11u3
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 278,368 kB
  • sloc: ansic: 1,025,361; asm: 256,790; makefile: 12,097; sh: 10,548; python: 9,618; cpp: 5,233; awk: 1,956; perl: 514; yacc: 290; pascal: 182; sed: 73
file content (44 lines) | stat: -rw-r--r-- 884 bytes parent folder | download | duplicates (22)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#include <array_length.h>
#include <stdio.h>
#include <string.h>

struct
{
  long double val;
  const char str[4][7];
} tests[] =
{
  { 0x0.FFFFp+0L, { "0X1P+0", "0X2P-1", "0X4P-2", "0X8P-3" } },
  { 0x0.FFFFp+1L, { "0X1P+1", "0X2P+0", "0X4P-1", "0X8P-2" } },
  { 0x0.FFFFp+2L, { "0X1P+2", "0X2P+1", "0X4P+0", "0X8P-1" } },
  { 0x0.FFFFp+3L, { "0X1P+3", "0X2P+2", "0X4P+1", "0X8P+0" } }
};

static int
do_test (void)
{
  char buf[100];
  int ret = 0;

  for (size_t i = 0; i < array_length (tests); ++i)
    {
      snprintf (buf, sizeof (buf), "%.0LA", tests[i].val);

      size_t j;
      for (j = 0; j < 4; ++j)
	if (strcmp (buf, tests[i].str[j]) == 0)
	  break;

      if (j == 4)
	{
	  printf ("%zd: got \"%s\", expected \"%s\" or equivalent\n",
		  i, buf, tests[i].str[0]);
	  ret = 1;
	}
    }

  return ret;
}

#define TEST_FUNCTION do_test ()
#include "../test-skeleton.c"