1#!/bin/sh
2# Test for this fix: 461231f022bdb3ee392622d31dc475034adceeb2.
3# Ensure that seq prints exactly two numbers for a 2-number integral
4# range at the limit of floating point precision.
5
6# Copyright (C) 2008-2023 Free Software Foundation, Inc.
7
8# This program is free software: you can redistribute it and/or modify
9# it under the terms of the GNU General Public License as published by
10# the Free Software Foundation, either version 3 of the License, or
11# (at your option) any later version.
12
13# This program is distributed in the hope that it will be useful,
14# but WITHOUT ANY WARRANTY; without even the implied warranty of
15# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16# GNU General Public License for more details.
17
18# You should have received a copy of the GNU General Public License
19# along with this program.  If not, see <https://www.gnu.org/licenses/>.
20
21. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
22print_ver_ seq
23getlimits_
24
25# Run this test only with glibc and sizeof (long double) > sizeof (double).
26# Otherwise, there are known failures.
27cat <<\EOF > long.c
28#include <features.h>
29#if defined __GNU_LIBRARY__ && __GLIBC__ >= 2
30int foo[sizeof (long double) - sizeof (double) - 1];
31#else
32"run this test only with glibc"
33#endif
34EOF
35$CC -c long.c \
36  || skip_ \
37     'this test runs only on systems with glibc and long double != double'
38
39a=$INTMAX_MAX
40b=$INTMAX_OFLOW
41
42seq $a $b > out || fail=1
43printf "$a\n$b\n" > exp || fail=1
44compare exp out || fail=1
45
46Exit $fail
47