logo

utils

~/.local/bin tools and git-hooks git clone https://hacktivis.me/git/utils.git
commit: 28a9f56416c894f8cde3388eee111d2a79d8ea6b
parent 96d6713ef3da859ba718d4e8f06ce9a0d5df7d94
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date:   Tue,  1 Mar 2022 18:51:41 +0100

test-bin/strings: Test usage

Diffstat:

Mbin/strings.c2+-
Mtest-bin/strings7+++++++
2 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/bin/strings.c b/bin/strings.c @@ -121,7 +121,7 @@ main(int argc, char *argv[]) } break; case 't': - if(strlen(optarg) > 1) + if(strnlen(optarg, 2) > 1) { usage(); return 1; diff --git a/test-bin/strings b/test-bin/strings @@ -75,6 +75,11 @@ decformat_body() { atf_check -o file:outputs/strings/true_8_td ../bin/strings -td -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 +} + atf_init_test_cases() { cd "$(atf_get_srcdir)" || exit 1 @@ -89,4 +94,6 @@ atf_init_test_cases() { atf_add_test_case octalformat atf_add_test_case hexformat atf_add_test_case decformat + + atf_add_test_case usage }