[PATCH 8/9] test: add boolean argument to arg-test

Jani Nikula jani at nikula.org
Tue Sep 19 13:39:28 PDT 2017


Surprisingly it's not there.
---
 test/T410-argument-parsing.sh | 3 ++-
 test/arg-test.c               | 5 +++++
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/test/T410-argument-parsing.sh b/test/T410-argument-parsing.sh
index fad134e305c5..4505c58301ea 100755
--- a/test/T410-argument-parsing.sh
+++ b/test/T410-argument-parsing.sh
@@ -3,8 +3,9 @@ test_description="argument parsing"
 . ./test-lib.sh || exit 1
 
 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
+boolean 1
 keyword 1
 flags 5
 int 7
diff --git a/test/arg-test.c b/test/arg-test.c
index 736686ded2c0..2f839c992c56 100644
--- a/test/arg-test.c
+++ b/test/arg-test.c
@@ -12,8 +12,10 @@ int main(int argc, char **argv){
     char *pos_arg1=NULL;
     char *pos_arg2=NULL;
     char *string_val=NULL;
+    notmuch_bool_t bool_val = FALSE;
 
     notmuch_opt_desc_t options[] = {
+	{ NOTMUCH_OPT_BOOLEAN, &bool_val, "boolean", 'b', 0},
 	{ NOTMUCH_OPT_KEYWORD, &kw_val, "keyword", 'k',
 	  (notmuch_keyword_t []){ { "one", 1 },
 				  { "two", 2 },
@@ -34,6 +36,9 @@ int main(int argc, char **argv){
     if (opt_index < 0)
 	return 1;
 
+    if (bool_val)
+	printf("boolean %d\n", bool_val);
+
     if (kw_val)
 	printf("keyword %d\n", kw_val);
 
-- 
2.11.0



More information about the notmuch mailing list