summaryrefslogtreecommitdiff
path: root/tests/t0030-integer-decimal-digits.sh
blob: 08f7fe2b591ec96529b0208f705fcd08df30c645 (plain)
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
#!/bin/sh
set -eu
base="${TMPDIR-/tmp}/mcpu-cpp-int-digs-$$"
mkdir -p "$base"
trap 'rm -rf "$base"' EXIT HUP INT TERM

"$MCPU_CPP" --no-config -dMP < /dev/null > "$base/macros"

check_digs()
{
  bits="$1"
  int_digs="$2"
  uint_digs="$3"

  grep "^#define __INT${bits}_DECIMAL_DIG__ ${int_digs}$" "$base/macros" >/dev/null
  grep "^#define __UINT${bits}_DECIMAL_DIG__ ${uint_digs}$" "$base/macros" >/dev/null
}

# Decimal digits of the numeric maxima only: no sign and no terminating NUL.
check_digs 8     3     3
check_digs 16    5     5
check_digs 32    10    10
check_digs 64    19    20
check_digs 128   39    39
check_digs 256   77    78
check_digs 512   154   155
check_digs 1024  308   309
check_digs 2048  617   617
check_digs 4096  1233  1234
check_digs 8192  2466  2467
check_digs 16384 4932  4933
check_digs 32768 9864  9865
check_digs 65536 19729 19729