OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-old/] [gcc-4.2.2/] [gcc/] [testsuite/] [gcc.dg/] [dfp/] [compare-eq.h] - Blame information for rev 867

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 149 jeremybenn
/* Basic test of runtime equality comparisons using simple values that
2
   are not affected by rounding.  */
3
 
4
#include <stdlib.h>
5
 
6
static int failcnt;
7
 
8
#define PASTE2(A,B) A ## B
9
#define PASTE(A,B) PASTE2(A,B)
10
 
11
#ifdef DBG
12
#include <stdio.h>
13
#define FAILURE(OP,KIND) \
14
  { printf ("failed at line %d: %s for %s values\n", __LINE__, OP, KIND); \
15
    failcnt++; }
16
#else
17
#define FAILURE(OP,KIND) abort ();
18
#endif
19
 
20
#ifndef WIDTH
21
#error define WIDTH as decimal float size in bytes
22
#endif
23
 
24
#if WIDTH == 32
25
#define DTYPE _Decimal32
26
#define SUFFIX DF
27
#elif WIDTH == 64
28
#define DTYPE _Decimal64
29
#define SUFFIX DD
30
#elif WIDTH == 128
31
#define DTYPE _Decimal128
32
#define SUFFIX DL
33
#elif WIDTH == 0
34
/* This is for testing the test using a type known to work.  */
35
#define DTYPE double
36
#define SUFFIX
37
#else
38
#error invalid width for decimal float type
39
#endif
40
 
41
DTYPE m_two = PASTE(-2.0, SUFFIX);
42
DTYPE m_one = PASTE(-1.0, SUFFIX);
43
DTYPE zero  = PASTE(0.0, SUFFIX);
44
DTYPE one   = PASTE(1.0, SUFFIX);
45
DTYPE two   = PASTE(2.0, SUFFIX);
46
 
47
void
48
test_compares (void)
49
{
50
  DTYPE x = one;
51
  DTYPE y = zero;
52
  DTYPE z = m_one;
53
 
54
  /* Equal to: comparisons against equal values.  */
55
 
56
  if (! (x == one))   FAILURE ("==", "equal")
57
  if (! (y == zero))  FAILURE ("==", "equal")
58
  if (! (z == m_one)) FAILURE ("==", "equal")
59
 
60
  /* Equal to: comparisons against lesser values.  */
61
 
62
  if (x == m_one)     FAILURE ("==", "lesser")
63
  if (x == zero)      FAILURE ("==", "lesser")
64
  if (y == m_one)     FAILURE ("==", "lesser")
65
  if (z == m_two)     FAILURE ("==", "lesser")
66
 
67
  /* Equal to: comparisons against greater values.  */
68
 
69
  if (x == two)       FAILURE ("==", "greater")
70
  if (y == one)       FAILURE ("==", "greater")
71
  if (z == zero)      FAILURE ("==", "greater")
72
  if (z == one)       FAILURE ("==", "greater")
73
 
74
  /* Not equal to: comparisons against equal values.  */
75
 
76
  if (x != one)        FAILURE ("!=", "equal")
77
  if (y != zero)       FAILURE ("!=", "equal")
78
  if (z != m_one)      FAILURE ("!=", "equal")
79
 
80
  /* Not equal to: comparisons against lesser values.  */
81
 
82
  if (! (x != m_one))  FAILURE ("!=", "lesser")
83
  if (! (x != zero))   FAILURE ("!=", "lesser")
84
  if (! (y != m_one))  FAILURE ("!=", "lesser")
85
  if (! (z != m_two))  FAILURE ("!=", "lesser")
86
 
87
  /* Not equal to: comparisons against greater values.  */
88
 
89
  if (! (x != m_one)) FAILURE ("!=", "greater")
90
  if (! (x != zero))  FAILURE ("!=", "greater")
91
  if (! (y != m_one)) FAILURE ("!=", "greater")
92
  if (! (z != m_two)) FAILURE ("!=", "greater")
93
 
94
  if (failcnt)
95
    abort ();
96
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.