X-Git-Url: http://git.openwrt.org/?p=project%2Fuci.git;a=blobdiff_plain;f=tests%2Fshunit2%2Ftests.d%2F020_get;fp=tests%2Fshunit2%2Ftests.d%2F020_get;h=630d84d9df8c3961d2f33f9503bfc246046ab764;hp=0000000000000000000000000000000000000000;hb=0ca93fec701a6779384c62e01fae2267922ded7a;hpb=fc417e808087f96466d9ce18819e16476af9527b diff --git a/tests/shunit2/tests.d/020_get b/tests/shunit2/tests.d/020_get new file mode 100644 index 0000000..630d84d --- /dev/null +++ b/tests/shunit2/tests.d/020_get @@ -0,0 +1,47 @@ +test_get_parsing() +{ + cp ${REF_DIR}/get_parsing.data ${CONFIG_DIR}/test + + assertFailWithNoReturn "${UCI_Q} get test." + assertFailWithNoReturn "${UCI_Q} get test.section." + assertFailWithNoReturn "${UCI_Q} get test.section.opt." + assertFailWithNoReturn "${UCI_Q} get test.section.opt.val." + assertFailWithNoReturn "${UCI_Q} get test.section.opt.val.qsdf.qsd" + assertFailWithNoReturn "${UCI_Q} get test.section.opt.valqsqsd" +} + +test_get_section_index_parsing() +{ + cp ${REF_DIR}/get_parsing.data ${CONFIG_DIR}/test + + assertFailWithNoReturn "${UCI_Q} get test.@" + assertFailWithNoReturn "${UCI_Q} get test.@zer." + assertFailWithNoReturn "${UCI_Q} get test.@." + assertFailWithNoReturn "${UCI_Q} get test.@zer[1]" + assertFailWithNoReturn "${UCI_Q} get test.@.opt" + assertFailWithNoReturn "${UCI_Q} get test.@[28]" + assertFailWithNoReturn "${UCI_Q} get test.@[1]." + assertFailWithNoReturn "${UCI_Q} get test.@[1].val." +} + +test_get_option() +{ + cp ${REF_DIR}/get.data ${CONFIG_DIR}/test + value=$($UCI get test.section.opt) + assertEquals 'val' "$value" +} + +test_get_option_multiline() +{ + cp ${REF_DIR}/get_multiline.data ${CONFIG_DIR}/test + value="$($UCI get test.section.opt)" + assertEquals '"Hello, World. +'\''' "$value" +} + +test_get_section() +{ + cp ${REF_DIR}/get.data ${CONFIG_DIR}/test + type=$($UCI get test.section) + assertEquals 'type' "$type" +}