summaryrefslogtreecommitdiff
path: root/tests/test-limits-h.c
diff options
context:
space:
mode:
authorJörg Frings-Fürst <debian@jff.email>2022-10-24 22:26:08 +0200
committerJörg Frings-Fürst <debian@jff.email>2022-10-24 22:26:08 +0200
commite97e0882ffc87a91e7818137196f1b74134566df (patch)
tree285662381eaa0514f988142bff0c8a9685c84dc0 /tests/test-limits-h.c
parentcc0876a2fa9e703b1064992ab535f3eed57e9c71 (diff)
parentcb4186bef1b44691db4221406d001a8d40c65b4b (diff)
Merge branch 'feature/upstream' into develop
Diffstat (limited to 'tests/test-limits-h.c')
-rw-r--r--tests/test-limits-h.c52
1 files changed, 25 insertions, 27 deletions
diff --git a/tests/test-limits-h.c b/tests/test-limits-h.c
index b1b1615..ddcb5d5 100644
--- a/tests/test-limits-h.c
+++ b/tests/test-limits-h.c
@@ -3,7 +3,7 @@
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 3 of the License, or
+ 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,
@@ -20,14 +20,12 @@
#include <limits.h>
-#include "verify.h"
-
#if 4 < __GNUC__ + (3 <= __GNUC_MINOR__)
# pragma GCC diagnostic ignored "-Woverlength-strings"
#endif
#define verify_width(width, min, max) \
- verify ((max) >> ((width) - 1 - ((min) < 0)) == 1)
+ static_assert ((max) >> ((width) - 1 - ((min) < 0)) == 1)
/* Macros borrowed from intprops.h. */
#define TYPE_SIGNED(t) (! ((t) 0 < (t) -1))
@@ -53,48 +51,48 @@ verify_width (LONG_BIT, LONG_MIN, LONG_MAX);
/* Numerical limit macros. */
char limits1[] = { CHAR_MIN, CHAR_MAX };
-verify (TYPE_MINIMUM (char) == CHAR_MIN);
-verify (TYPE_MAXIMUM (char) == CHAR_MAX);
+static_assert (TYPE_MINIMUM (char) == CHAR_MIN);
+static_assert (TYPE_MAXIMUM (char) == CHAR_MAX);
signed char limits2[] = { SCHAR_MIN, SCHAR_MAX };
-verify (TYPE_MINIMUM (signed char) == SCHAR_MIN);
-verify (TYPE_MAXIMUM (signed char) == SCHAR_MAX);
+static_assert (TYPE_MINIMUM (signed char) == SCHAR_MIN);
+static_assert (TYPE_MAXIMUM (signed char) == SCHAR_MAX);
unsigned char limits3[] = { UCHAR_MAX };
-verify (TYPE_MINIMUM (unsigned char) == 0);
-verify (TYPE_MAXIMUM (unsigned char) == UCHAR_MAX);
+static_assert (TYPE_MINIMUM (unsigned char) == 0);
+static_assert (TYPE_MAXIMUM (unsigned char) == UCHAR_MAX);
short limits4[] = { SHRT_MIN, SHRT_MAX };
-verify (TYPE_MINIMUM (short int) == SHRT_MIN);
-verify (TYPE_MAXIMUM (short int) == SHRT_MAX);
+static_assert (TYPE_MINIMUM (short int) == SHRT_MIN);
+static_assert (TYPE_MAXIMUM (short int) == SHRT_MAX);
unsigned short limits5[] = { USHRT_MAX };
-verify (TYPE_MINIMUM (unsigned short int) == 0);
-verify (TYPE_MAXIMUM (unsigned short int) == USHRT_MAX);
+static_assert (TYPE_MINIMUM (unsigned short int) == 0);
+static_assert (TYPE_MAXIMUM (unsigned short int) == USHRT_MAX);
int limits6[] = { INT_MIN, INT_MAX };
-verify (TYPE_MINIMUM (int) == INT_MIN);
-verify (TYPE_MAXIMUM (int) == INT_MAX);
+static_assert (TYPE_MINIMUM (int) == INT_MIN);
+static_assert (TYPE_MAXIMUM (int) == INT_MAX);
unsigned int limits7[] = { UINT_MAX };
-verify (TYPE_MINIMUM (unsigned int) == 0);
-verify (TYPE_MAXIMUM (unsigned int) == UINT_MAX);
+static_assert (TYPE_MINIMUM (unsigned int) == 0);
+static_assert (TYPE_MAXIMUM (unsigned int) == UINT_MAX);
long limits8[] = { LONG_MIN, LONG_MAX };
-verify (TYPE_MINIMUM (long int) == LONG_MIN);
-verify (TYPE_MAXIMUM (long int) == LONG_MAX);
+static_assert (TYPE_MINIMUM (long int) == LONG_MIN);
+static_assert (TYPE_MAXIMUM (long int) == LONG_MAX);
unsigned long limits9[] = { ULONG_MAX };
-verify (TYPE_MINIMUM (unsigned long int) == 0);
-verify (TYPE_MAXIMUM (unsigned long int) == ULONG_MAX);
+static_assert (TYPE_MINIMUM (unsigned long int) == 0);
+static_assert (TYPE_MAXIMUM (unsigned long int) == ULONG_MAX);
long long limits10[] = { LLONG_MIN, LLONG_MAX };
-verify (TYPE_MINIMUM (long long int) == LLONG_MIN);
-verify (TYPE_MAXIMUM (long long int) == LLONG_MAX);
+static_assert (TYPE_MINIMUM (long long int) == LLONG_MIN);
+static_assert (TYPE_MAXIMUM (long long int) == LLONG_MAX);
unsigned long long limits11[] = { ULLONG_MAX };
-verify (TYPE_MINIMUM (unsigned long long int) == 0);
-verify (TYPE_MAXIMUM (unsigned long long int) == ULLONG_MAX);
+static_assert (TYPE_MINIMUM (unsigned long long int) == 0);
+static_assert (TYPE_MAXIMUM (unsigned long long int) == ULLONG_MAX);
/* Macros specified by ISO/IEC TS 18661-1:2014. */
@@ -113,7 +111,7 @@ verify_width (ULLONG_WIDTH, 0, ULLONG_MAX);
/* Macros specified by C2x. */
int bool_attrs[] = { BOOL_MAX, BOOL_WIDTH };
-verify (BOOL_MAX == (((1U << (BOOL_WIDTH - 1)) - 1) * 2) + 1);
+static_assert (BOOL_MAX == (((1U << (BOOL_WIDTH - 1)) - 1) * 2) + 1);
int
main (void)