1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
|
#!/bin/bash
# added 2015-09-02 by Rainer Gerhards
# This file is part of the liblognorm project, released under ASL 2.0
. $srcdir/exec.sh
no_solaris10
test_def $0 "string syntax"
reset_rules
add_rule 'version=2'
add_rule 'rule=:a %f:string% b'
execute 'a test b'
assert_output_json_eq '{"f": "test"}'
execute 'a "test" b'
assert_output_json_eq '{"f": "test"}'
execute 'a "test with space" b'
assert_output_json_eq '{"f": "test with space"}'
execute 'a "test with "" double escape" b'
assert_output_json_eq '{ "f": "test with \" double escape" }'
execute 'a "test with \" backslash escape" b'
assert_output_json_eq '{ "f": "test with \" backslash escape" }'
echo test quoting.mode
reset_rules
add_rule 'version=2'
add_rule 'rule=:a %f:string{"quoting.mode":"none"}% b'
execute 'a test b'
assert_output_json_eq '{"f": "test"}'
execute 'a "test" b'
assert_output_json_eq '{"f": "\"test\""}'
echo "test quoting.char.*"
reset_rules
add_rule 'version=2'
add_rule 'rule=:a %f:string{"quoting.char.begin":"[", "quoting.char.end":"]"}% b'
execute 'a test b'
assert_output_json_eq '{"f": "test"}'
execute 'a [test] b'
assert_output_json_eq '{"f": "test"}'
execute 'a [test test2] b'
assert_output_json_eq '{"f": "test test2"}'
# things that need to NOT match
cleanup_tmp_files
|