3 # Copyright (c) 2012 Michael Haggerty
6 test_description
='Test string list functionality'
12 test_expect_success
"split $1 at $2, max $3" "
13 test-string-list split '$1' '$2' '$3' >actual &&
14 test_cmp expected actual &&
15 test-string-list split_in_place '$1' '$2' '$3' >actual &&
16 test_cmp expected actual
20 test_split
"foo:bar:baz" ":" "-1" <<EOF
27 test_split
"foo:bar:baz" ":" "0" <<EOF
32 test_split
"foo:bar:baz" ":" "1" <<EOF
38 test_split
"foo:bar:baz" ":" "2" <<EOF
45 test_split
"foo:bar:" ":" "-1" <<EOF
52 test_split
"" ":" "-1" <<EOF
57 test_split
":" ":" "-1" <<EOF
63 test_expect_success
"test filter_string_list" '
64 test "x-" = "x$(test-string-list filter - y)" &&
65 test "x-" = "x$(test-string-list filter no y)" &&
66 test yes = "$(test-string-list filter yes y)" &&
67 test yes = "$(test-string-list filter no:yes y)" &&
68 test yes = "$(test-string-list filter yes:no y)" &&
69 test y1:y2 = "$(test-string-list filter y1:y2 y)" &&
70 test y2:y1 = "$(test-string-list filter y2:y1 y)" &&
71 test "x-" = "x$(test-string-list filter x1:x2 y)"