mirror of
https://git.notmuchmail.org/git/notmuch
synced 2024-11-21 18:38:08 +01:00
test: add boolean argument to arg-test
Surprisingly it's not there.
This commit is contained in:
parent
4a6721970a
commit
e8cba9da18
2 changed files with 7 additions and 1 deletions
|
@ -3,8 +3,9 @@ test_description="argument parsing"
|
||||||
. ./test-lib.sh || exit 1
|
. ./test-lib.sh || exit 1
|
||||||
|
|
||||||
test_begin_subtest "sanity check"
|
test_begin_subtest "sanity check"
|
||||||
$TEST_DIRECTORY/arg-test pos1 --keyword=one --string=foo pos2 --int=7 --flag=one --flag=three > OUTPUT
|
$TEST_DIRECTORY/arg-test pos1 --keyword=one --boolean --string=foo pos2 --int=7 --flag=one --flag=three > OUTPUT
|
||||||
cat <<EOF > EXPECTED
|
cat <<EOF > EXPECTED
|
||||||
|
boolean 1
|
||||||
keyword 1
|
keyword 1
|
||||||
flags 5
|
flags 5
|
||||||
int 7
|
int 7
|
||||||
|
|
|
@ -12,8 +12,10 @@ int main(int argc, char **argv){
|
||||||
const char *pos_arg1=NULL;
|
const char *pos_arg1=NULL;
|
||||||
const char *pos_arg2=NULL;
|
const char *pos_arg2=NULL;
|
||||||
const char *string_val=NULL;
|
const char *string_val=NULL;
|
||||||
|
notmuch_bool_t bool_val = FALSE;
|
||||||
|
|
||||||
notmuch_opt_desc_t options[] = {
|
notmuch_opt_desc_t options[] = {
|
||||||
|
{ .opt_bool = &bool_val, .name = "boolean" },
|
||||||
{ .opt_keyword = &kw_val, .name = "keyword", .keywords =
|
{ .opt_keyword = &kw_val, .name = "keyword", .keywords =
|
||||||
(notmuch_keyword_t []){ { "one", 1 },
|
(notmuch_keyword_t []){ { "one", 1 },
|
||||||
{ "two", 2 },
|
{ "two", 2 },
|
||||||
|
@ -35,6 +37,9 @@ int main(int argc, char **argv){
|
||||||
if (opt_index < 0)
|
if (opt_index < 0)
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
|
if (bool_val)
|
||||||
|
printf("boolean %d\n", bool_val);
|
||||||
|
|
||||||
if (kw_val)
|
if (kw_val)
|
||||||
printf("keyword %d\n", kw_val);
|
printf("keyword %d\n", kw_val);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue