2 |
# Copyright 2008 by Denys Vlasenko |
# Copyright 2008 by Denys Vlasenko |
3 |
# Licensed under GPL v2, see file LICENSE for details. |
# Licensed under GPL v2, see file LICENSE for details. |
4 |
|
|
5 |
. testing.sh |
. ./testing.sh |
6 |
|
|
7 |
# Need this in order to not execute shell builtin |
# Need this in order to not execute shell builtin |
8 |
bb="busybox " |
bb="busybox " |
79 |
"-5\n""0\n" \ |
"-5\n""0\n" \ |
80 |
"" "" |
"" "" |
81 |
|
|
82 |
# We are "more correct" here than bash/coreutils: they happily print -2 |
# "FIXED" now to act compatibly |
83 |
# as if it is a huge unsigned number |
## We are "more correct" here than bash/coreutils: they happily print -2 |
84 |
testing "printf handles %u -N" \ |
## as if it is a huge unsigned number |
85 |
"${bb}printf '%u\n' 1 -2 3 2>&1; echo \$?" \ |
#testing "printf handles %u -N" \ |
86 |
"1\n""printf: -2: invalid number\n""0\n""3\n""0\n" \ |
# "${bb}printf '%u\n' 1 -2 3 2>&1; echo \$?" \ |
87 |
"" "" |
# "1\n""printf: -2: invalid number\n""0\n""3\n""0\n" \ |
88 |
|
# "" "" |
89 |
|
|
|
# Actually, we are wrong here: exit code should be 1 |
|
90 |
testing "printf handles %d bad_input" \ |
testing "printf handles %d bad_input" \ |
91 |
"${bb}printf '%d\n' 1 - 2 bad 3 123bad 4 2>&1; echo \$?" \ |
"${bb}printf '%d\n' 1 - 2 bad 3 123bad 4 2>&1; echo \$?" \ |
92 |
"1\n""printf: -: invalid number\n""0\n"\ |
"1\n""printf: -: invalid number\n""0\n"\ |
93 |
"2\n""printf: bad: invalid number\n""0\n"\ |
"2\n""printf: bad: invalid number\n""0\n"\ |
94 |
"3\n""printf: 123bad: invalid number\n""0\n"\ |
"3\n""printf: 123bad: invalid number\n""0\n"\ |
95 |
"4\n""0\n" \ |
"4\n""1\n" \ |
96 |
"" "" |
"" "" |
97 |
|
|
98 |
testing "printf aborts on bare %" \ |
testing "printf aborts on bare %" \ |