diff options
| author | Ulf Magnusson <ulfalizer@gmail.com> | 2012-12-18 12:55:44 +0100 |
|---|---|---|
| committer | Ulf Magnusson <ulfalizer@gmail.com> | 2012-12-18 12:55:44 +0100 |
| commit | 60c48adcfb64ae14205bf4686cf96a219b703835 (patch) | |
| tree | 4fc047f3273b74ac4210f353736727c922f8dff4 /testsuite.py | |
| parent | 78753dead7c115801ac3ad70fe47c790dc269a34 (diff) | |
Add selftests for reading strings with escaped characters.
Diffstat (limited to 'testsuite.py')
| -rw-r--r-- | testsuite.py | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/testsuite.py b/testsuite.py index 7bb7de1..a075603 100644 --- a/testsuite.py +++ b/testsuite.py @@ -199,8 +199,8 @@ def run_selftests(): verify_string_lex(r""" "\\" """, "\\") verify_string_lex(r""" '\\' """, "\\") - verify_string_lex(r""" "\a\\\b\c\"'d" """, 'a\\bc"\'d') - verify_string_lex(r""" '\a\\\b\c\'"d' """, "a\\bc'\"d") + verify_string_lex(r""" "\a\\'\b\c\"'d" """, 'a\\\'bc"\'d') + verify_string_lex(r""" '\a\\"\b\c\'"d' """, "a\\\"bc'\"d") def verify_string_bad(s): """Verifies that tokenizing 's' throws a Kconfig_Syntax_Error. Strips @@ -1185,20 +1185,26 @@ def run_selftests(): "{0} contains '{1}'. Expected '{2}'." .format(fname, file_contents, contents)) - # Writing strings with characters that need to be escaped + # Writing/reading strings with characters that need to be escaped - c = kconfiglib.Config("Kconfiglib/tests/Kstring") + c = kconfiglib.Config("Kconfiglib/tests/Kescape") # Test the default value - c.write_config(config_test_file) - verify_file_contents(config_test_file, + c.write_config(config_test_file + "_from_def") + verify_file_contents(config_test_file + "_from_def", r'''CONFIG_STRING="\"\\"''' "\n") # Write our own value c["STRING"].set_user_value(r'''\"a'\\''') - c.write_config(config_test_file) - verify_file_contents(config_test_file, + c.write_config(config_test_file + "_from_user") + verify_file_contents(config_test_file + "_from_user", r'''CONFIG_STRING="\\\"a'\\\\"''' "\n") + # Read back the two configs and verify the respective values + c.load_config(config_test_file + "_from_def") + verify_value("STRING", '"\\') + c.load_config(config_test_file + "_from_user") + verify_value("STRING", r'''\"a'\\''') + # Reading and writing of .config headers read_header = c.get_config_header() |
