From 3579a2ee08a199e8a191a56a183ad9090e2271b5 Mon Sep 17 00:00:00 2001 From: Pavel Rehak Date: Sat, 26 May 2018 14:21:21 +0200 Subject: [PATCH] Test case - array. --- t/Makefile.am | 2 +- t/t0008-array.sh | 36 ++++++++++++++++++++++++++++++++++++ t/t0008/array.ini | 6 ++++++ 3 files changed, 43 insertions(+), 1 deletion(-) create mode 100755 t/t0008-array.sh create mode 100644 t/t0008/array.ini diff --git a/t/Makefile.am b/t/Makefile.am index 165f303..603ac6b 100644 --- a/t/Makefile.am +++ b/t/Makefile.am @@ -1,4 +1,4 @@ TEST_LOG_DRIVER = env AM_TAP_AWK='$(AWK)' $(SHELL) \ $(top_srcdir)/build-aux/tap-driver.sh -TESTS = t0001-whitespace.sh t0002-invalid.sh t0003-sections.sh t0004-comments.sh t0005-new_var.sh t0006-duplication.sh t0007-unwanted_file.sh +TESTS = t0001-whitespace.sh t0002-invalid.sh t0003-sections.sh t0004-comments.sh t0005-new_var.sh t0006-duplication.sh t0007-unwanted_file.sh t0008-array.sh EXTRA_DIST = $(TESTS) diff --git a/t/t0008-array.sh b/t/t0008-array.sh new file mode 100755 index 0000000..1339893 --- /dev/null +++ b/t/t0008-array.sh @@ -0,0 +1,36 @@ +#!/bin/bash + +test_description="check array" + +. setup.sh + +DIR_TEST=$SHARNESS_TEST_DIRECTORY/t0008 + +test_array() +{ +export COVERAGE_NAME=array_parser +cp ../.simplecov . + +# Parse sec1 array +cfg_parser $DIR_TEST/array.ini +cfg_section_sec1 +[ $var1 = foo ] || return 1 +[ ${var1[1]} = bar ] || return 1 + +# Update sec2 var +var2=foo_new +cfg_update sec2 var2 +cfg_writer > array.out + +# Parse sec1 array again +cfg_parser array.out +cfg_section_sec1 +[ $var1 = foo ] || return 1 +[ ${var1[1]} = bar ] || return 1 +} + +test_expect_success "Parse array" " + test_expect_code 0 test_array +" + +test_done diff --git a/t/t0008/array.ini b/t/t0008/array.ini new file mode 100644 index 0000000..0279c59 --- /dev/null +++ b/t/t0008/array.ini @@ -0,0 +1,6 @@ +[sec1] +var1=foo bar +var2=foo2 +[sec2] +var1=foo bar +var2=foo2