Imported Upstream version 6.0.0
[platform/upstream/gmp.git] / tests / t-gmpmax.c
1 /* Check the values of __GMP_UINT_MAX etc.
2
3 Copyright 2001 Free Software Foundation, Inc.
4
5 This file is part of the GNU MP Library test suite.
6
7 The GNU MP Library test suite is free software; you can redistribute it
8 and/or modify it under the terms of the GNU General Public License as
9 published by the Free Software Foundation; either version 3 of the License,
10 or (at your option) any later version.
11
12 The GNU MP Library test suite is distributed in the hope that it will be
13 useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General
15 Public License for more details.
16
17 You should have received a copy of the GNU General Public License along with
18 the GNU MP Library test suite.  If not, see https://www.gnu.org/licenses/.  */
19
20 #include <stdio.h>
21 #include <stdlib.h>
22 #include <limits.h>
23 #include "gmp.h"
24
25
26 /* __GMP_UINT_MAX etc are generated with expressions in gmp.h since we don't
27    want to demand <limits.h> or forcibly include it.  Check the expressions
28    come out the same as <limits.h>.  */
29
30 int
31 main (int argc, char *argv[])
32 {
33   int  error = 0;
34
35 #ifdef UINT_MAX
36   if (__GMP_UINT_MAX != UINT_MAX)
37     {
38       printf ("__GMP_UINT_MAX incorrect\n");
39       printf ("  __GMP_UINT_MAX  %u  0x%X\n", __GMP_UINT_MAX, __GMP_UINT_MAX);
40       printf ("  UINT_MAX        %u  0x%X\n", UINT_MAX, UINT_MAX);
41       error = 1;
42     }
43 #endif
44
45 #ifdef ULONG_MAX
46   if (__GMP_ULONG_MAX != ULONG_MAX)
47     {
48       printf ("__GMP_ULONG_MAX incorrect\n");
49       printf ("  __GMP_ULONG_MAX  %lu  0x%lX\n", __GMP_ULONG_MAX, __GMP_ULONG_MAX);
50       printf ("  ULONG_MAX        %lu  0x%lX\n", ULONG_MAX, ULONG_MAX);
51       error = 1;
52     }
53 #endif
54
55 #ifdef USHRT_MAX
56   if (__GMP_USHRT_MAX != USHRT_MAX)
57     {
58       printf ("__GMP_USHRT_MAX incorrect\n");
59       printf ("  __GMP_USHRT_MAX  %u  0x%X\n", __GMP_USHRT_MAX, __GMP_USHRT_MAX);
60       printf ("  USHRT_MAX        %u  0x%X\n", USHRT_MAX, USHRT_MAX);
61       error = 1;
62     }
63 #endif
64
65   if (error)
66     abort ();
67
68   exit (0);
69 }