7fd30ba3117c6697d603e8c884b00fe7da7e1f5b
[project/uci.git] / test / tests.d / 020_get
1 test_get_parsing()
2 {
3 cp ${REF_DIR}/get_parsing.data ${CONFIG_DIR}/test
4
5 assertFailWithNoReturn "${UCI_Q} get test."
6 assertFailWithNoReturn "${UCI_Q} get test.section."
7 assertFailWithNoReturn "${UCI_Q} get test.section.opt."
8 assertFailWithNoReturn "${UCI_Q} get test.section.opt.val."
9 assertFailWithNoReturn "${UCI_Q} get test.section.opt.val.qsdf.qsd"
10 assertFailWithNoReturn "${UCI_Q} get test.section.opt.valqsqsd"
11 }
12
13 test_get_section_index_parsing()
14 {
15 cp ${REF_DIR}/get_parsing.data ${CONFIG_DIR}/test
16
17 assertFailWithNoReturn "${UCI_Q} get test.@"
18 assertFailWithNoReturn "${UCI_Q} get test.@zer."
19 assertFailWithNoReturn "${UCI_Q} get test.@."
20 assertFailWithNoReturn "${UCI_Q} get test.@zer[1]"
21 assertFailWithNoReturn "${UCI_Q} get test.@.opt"
22 assertFailWithNoReturn "${UCI_Q} get test.@[28]"
23 assertFailWithNoReturn "${UCI_Q} get test.@[1]."
24 assertFailWithNoReturn "${UCI_Q} get test.@[1].val."
25 }
26
27 test_get_option()
28 {
29 cp ${REF_DIR}/get.data ${CONFIG_DIR}/test
30 value=$($UCI get test.section.opt)
31 assertEquals 'val' "$value"
32 }
33
34 test_get_option_multiline()
35 {
36 cp ${REF_DIR}/get_multiline.data ${CONFIG_DIR}/test
37 value="$($UCI get test.section.opt)"
38 echo "$value"
39 assertEquals '"Hello, World.
40 '\''' "$value"
41 }
42
43 test_get_section()
44 {
45 cp ${REF_DIR}/get.data ${CONFIG_DIR}/test
46 type=$($UCI get test.section)
47 assertEquals 'type' "$type"
48 }