logo

utils

~/.local/bin tools and git-hooks git clone https://hacktivis.me/git/utils.git
commit: 00a9ba524d22602287df3d8ea8acbd9d6e2b7206
parent 90969537e067d6b2b8525f38b96f1786106c5cc5
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date:   Fri, 11 Mar 2022 20:41:56 +0100

test-bin/strings: Add `badformat` test

Diffstat:

Mbin/seq.c4++--
Mbin/sname.c7++++++-
Mtest-bin/strings11+++++++++++
3 files changed, 19 insertions(+), 3 deletions(-)

diff --git a/bin/seq.c b/bin/seq.c @@ -21,12 +21,12 @@ seq(long i, long step, long last) } else if(i < last) { - for(;i <= last; i += step) + for(; i <= last; i += step) printf("%li%s", i, separator); } else if(i > last) { - for(;i >= last; i -= step) + for(; i >= last; i -= step) printf("%li%s", i, separator); } } diff --git a/bin/sname.c b/bin/sname.c @@ -15,7 +15,12 @@ main() return 1; } - int ret = printf("sysname=%s\nnodename=%s\nrelease=%s\nversion=%s\nmachine=%s\n", name.sysname, name.nodename, name.release, name.version, name.machine); + int ret = printf("sysname=%s\nnodename=%s\nrelease=%s\nversion=%s\nmachine=%s\n", + name.sysname, + name.nodename, + name.release, + name.version, + name.machine); if(ret < 0) { perror("sname"); diff --git a/test-bin/strings b/test-bin/strings @@ -72,6 +72,16 @@ decformat_body() { atf_check -o file:outputs/strings/true_8_td ../bin/strings -td -n 8 inputs/strings/true } +atf_test_case badformat +badformat_body() { + usage="strings: [-a] [-t format] [-n number] [file...]\n" + + atf_check -s exit:1 -o "inline:${usage}" ../bin/strings -tt inputs/all_bytes + atf_check -s exit:1 -o "inline:${usage}" ../bin/strings -tt /dev/null + atf_check -s exit:1 -o "inline:${usage}" ../bin/strings -tt inputs/strings/true + atf_check -s exit:1 -o "inline:${usage}" ../bin/strings -tt -n 8 inputs/strings/true +} + atf_test_case usage usage_body() { atf_check -s exit:1 -o 'inline:strings: [-a] [-t format] [-n number] [file...]\n' ../bin/strings -t aa inputs/all_bytes @@ -93,6 +103,7 @@ atf_init_test_cases() { atf_add_test_case octalformat atf_add_test_case hexformat atf_add_test_case decformat + atf_add_test_case badformat atf_add_test_case usage }