diff options
author | Rafael G. Martins <rafael@rafaelmartins.eng.br> | 2016-12-20 18:05:51 +0100 |
---|---|---|
committer | Rafael G. Martins <rafael@rafaelmartins.eng.br> | 2016-12-20 18:05:51 +0100 |
commit | 209ea0657b7970b4b8069ce44b43eecb97681892 (patch) | |
tree | 681a531d2d49fa4f12eecc94649069ef0b4d5e1b /tests/common | |
parent | 08fe4ebf7c6b5430134a22177079eadb08d71cdc (diff) | |
download | blogc-209ea0657b7970b4b8069ce44b43eecb97681892.tar.gz blogc-209ea0657b7970b4b8069ce44b43eecb97681892.tar.bz2 blogc-209ea0657b7970b4b8069ce44b43eecb97681892.zip |
config-parser: improved error reporting, added bc_config_get_with_default
Diffstat (limited to 'tests/common')
-rw-r--r-- | tests/common/check_config_parser.c | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/tests/common/check_config_parser.c b/tests/common/check_config_parser.c index 2a6ad67..66003e0 100644 --- a/tests/common/check_config_parser.c +++ b/tests/common/check_config_parser.c @@ -29,6 +29,7 @@ test_config_empty(void **state) assert_non_null(c); assert_non_null(c->root); assert_int_equal(bc_trie_size(c->root), 0); + assert_string_equal(bc_config_get_with_default(c, "bola", "foo", "bar"), "bar"); bc_config_free(c); } @@ -369,7 +370,9 @@ test_config_error_start(void **state) assert_non_null(err); assert_null(c); assert_int_equal(err->type, BC_ERROR_CONFIG_PARSER); - assert_string_equal(err->msg, "File must start with section"); + assert_string_equal(err->msg, + "File must start with section.\n" + "Error occurred near line 1, position 1: asd"); bc_error_free(err); } @@ -384,7 +387,9 @@ test_config_error_section_with_newline(void **state) assert_non_null(err); assert_null(c); assert_int_equal(err->type, BC_ERROR_CONFIG_PARSER); - assert_string_equal(err->msg, "Section names can't have new lines"); + assert_string_equal(err->msg, + "Section names can't have new lines.\n" + "Error occurred near line 1, position 5: [foo"); bc_error_free(err); } @@ -401,7 +406,9 @@ test_config_error_key_without_value(void **state) assert_non_null(err); assert_null(c); assert_int_equal(err->type, BC_ERROR_CONFIG_PARSER); - assert_string_equal(err->msg, "Key without value: foo"); + assert_string_equal(err->msg, + "Key without value: foo.\n" + "Error occurred near line 3, position 3: foo"); bc_error_free(err); a = "[foobar]\n" @@ -412,7 +419,9 @@ test_config_error_key_without_value(void **state) assert_non_null(err); assert_null(c); assert_int_equal(err->type, BC_ERROR_CONFIG_PARSER); - assert_string_equal(err->msg, "Key without value: foo"); + assert_string_equal(err->msg, + "Key without value: foo.\n" + "Error occurred near line 3, position 4: foo"); bc_error_free(err); } |