tests: Separate invalid escaping tests for GKeyFile

One test key was serving two purposes, which meant tests for it couldn’t
be separated out. It was testing escape-at-end-of-line and also
invalid-escape.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>

Helps: #3098
This commit is contained in:
Philip Withnall 2023-10-04 11:08:29 +01:00
parent 76d77cf623
commit ef28253e57

View File

@ -589,8 +589,9 @@ test_string (void)
"key6=trailing space \n"
"[invalid]\n"
"key1=\\a\\b\\0800xff\n"
"key2=blabla\\\n"
"key3=foo\\i\\\n";
"key2=blabla\\\n" /* escape at end of line */
"key3=\\ifoo\n" /* invalid escape */
"key4=\\i\\hfoo\n"; /* invalid escape with multiple stacked errors */
keyfile = load_data (data, 0);
@ -613,6 +614,10 @@ test_string (void)
check_error (&error, G_KEY_FILE_ERROR, G_KEY_FILE_ERROR_INVALID_VALUE);
g_free (value);
value = g_key_file_get_string (keyfile, "invalid", "key4", &error);
check_error (&error, G_KEY_FILE_ERROR, G_KEY_FILE_ERROR_INVALID_VALUE);
g_free (value);
g_key_file_set_string (keyfile, "inserted", "key1", "simple");
g_key_file_set_string (keyfile, "inserted", "key2", " leading space");
g_key_file_set_string (keyfile, "inserted", "key3", "\tleading tab");