logo

utils

~/.local/bin tools and git-hooks git clone https://hacktivis.me/git/utils.git
commit: 1c2f22f8165ceb3c336ac09e6aad91e7a700c8b0
parent 73bdd8bfd1c062713d773e37cb9eb60d1d23957e
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date:   Tue,  8 Jun 2021 05:21:35 +0200

test-bin/args: New test

Diffstat:

Mtest-bin/Kyuafile3++-
Atest-bin/args44++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 46 insertions(+), 1 deletion(-)

diff --git a/test-bin/Kyuafile b/test-bin/Kyuafile @@ -2,6 +2,7 @@ syntax(2) test_suite("utils") -atf_test_program{name="xcd"} +atf_test_program{name="args"} atf_test_program{name="basename"} atf_test_program{name="dirname"} +atf_test_program{name="xcd"} diff --git a/test-bin/args b/test-bin/args @@ -0,0 +1,44 @@ +#!/usr/bin/env atf-sh + +atf_test_case noargs +noargs_body() { + atf_check -o 'inline:argc: 1 +argv[0]: "../bin/args" +' ../bin/args +} + +atf_test_case onearg +onearg_body() { + atf_check -o 'inline:argc: 2 +argv[0]: "../bin/args" +argv[1]: "a" +' ../bin/args a +} + +atf_test_case twoargs +twoargs_body() { + atf_check -o 'inline:argc: 3 +argv[0]: "../bin/args" +argv[1]: "a" +argv[2]: "b c" +' ../bin/args a 'b c' +} + +atf_test_case options +options_body() { + atf_check -o 'inline:argc: 5 +argv[0]: "../bin/args" +argv[1]: "-1" +argv[2]: "+2" +argv[3]: "--3" +argv[4]: "/4" +' ../bin/args -1 +2 --3 /4 +} + +atf_init_test_cases() { + cd "$(atf_get_srcdir)" + atf_add_test_case noargs + atf_add_test_case onearg + atf_add_test_case twoargs + atf_add_test_case options +}