3 if [ -z "$srcdir" ] ; then
8 printf "%s" "$1" > "$2"
12 printf "%s\n" "$1" > "$2"
16 print_raw "$1" test.in
17 if ../tools/sexp-conv -s advanced <test.in >test1.out ; then
22 print_nl "$2" test2.out
24 if cmp test1.out test2.out ; then
31 test_advanced_hex () {
32 print_raw "$1" test.in
33 if ../tools/sexp-conv -s hex <test.in >test1.out ; then
38 print_nl "$2" test2.out
40 if cmp test1.out test2.out ; then
48 print_raw "$1" test.in
49 if ../tools/sexp-conv -s transport <test.in >test1.out ; then
54 print_nl "$2" test2.out
56 if cmp test1.out test2.out ; then
64 print_raw "$1" test.in
65 if ../tools/sexp-conv -s canonical <test.in >test1.out ; then
70 print_raw "$2" test2.out
72 if cmp test1.out test2.out ; then
79 test_advanced '0:' '""'
80 test_advanced '3:foo' 'foo'
81 test_advanced '12:fooooooooooo' 'fooooooooooo'
82 test_advanced '10:fooooooooo' 'fooooooooo'
83 test_advanced '4:3des' '"3des"'
84 test_advanced '"foo"' 'foo'
87 # Having the string end with a \ breaks with sysv echo. \x seems harmless.
88 test_advanced '3:"\x' '"\"\\x"'
89 test_advanced '()' '()'
90 test_advanced '(foo bar baz)' '(foo bar
92 test_advanced '; comment
95 test_advanced '(foo ; gazonk
99 test_advanced '(foo[bar]foo)' '(foo [bar]foo)'
101 test_advanced '(#aabb#)' '(|qrs=|)'
102 test_advanced '(|qrs=|)' '(|qrs=|)'
103 test_advanced_hex '(|qrs=|)' '(#aabb#)'
104 test_advanced_hex '(#aabb#)' '(#aabb#)'
105 test_advanced_hex '{MToR}' '#11#'
106 test_advanced_hex '|EQ==|' '#11#'
108 test_transport '0:' '{MDo=}'
109 test_transport '()' '{KCk=}'
110 test_transport '1:A' '{MTpB}'
111 test_transport 'foo' '{Mzpmb28=}'
112 test_transport '(foo bar baz)' '{KDM6Zm9vMzpiYXIzOmJheik=}'
114 test_canonical '""' '0:'
115 test_canonical '{MDo=}' '0:'
116 test_canonical '{KCk=}' '()'
117 test_canonical '{MTpB}' '1:A'
118 test_canonical 'foo' '3:foo'
119 test_canonical 'fooooooooooo' '12:fooooooooooo'
120 test_canonical 'fooooooooo' '10:fooooooooo'
121 test_canonical '(foo bar baz)' '(3:foo3:bar3:baz)'
122 test_canonical '{KDM6Zm9vMzpiYXIzOmJheik=}' '(3:foo3:bar3:baz)'