Browse Source

+ t/t_config_param.c

master
Alex 'AdUser' Z 9 years ago
parent
commit
14cf3a64de
  1. 2
      t/CMakeLists.txt
  2. 38
      t/t_config_param.c

2
t/CMakeLists.txt

@ -6,8 +6,10 @@ add_executable("t_logfile" "t_logfile.c" "${SRC_DIR}/logfile.c")
add_executable("t_matches" "t_matches.c" "${SRC_DIR}/matches.c")
add_executable("t_ipaddr" "t_ipaddr.c" "${SRC_DIR}/ipaddr.c" "${SRC_DIR}/matches.c")
add_executable("t_rx_posix" "t_rx_posix.c" "${SRC_DIR}/regexps_posix.c")
add_executable("t_config_param" "t_config_param.c" "${SRC_DIR}/config.c" "${SRC_DIR}/log.c")
add_test("tests/f2b_logfile_*" "t_logfile")
add_test("tests/f2b_matches_*" "t_matches")
add_test("tests/f2b_ipaddr_*" "t_ipaddr")
add_test("tests/f2b_regex_*" "t_rx_posix")
add_test("tests/f2b_config_param*" "t_config_param")

38
t/t_config_param.c

@ -0,0 +1,38 @@
#include "../src/common.h"
#include "../src/config.h"
int main() {
f2b_config_param_t *param = NULL;
assert(f2b_config_parse_kv_pair("") == NULL);
assert(f2b_config_parse_kv_pair("#") == NULL);
assert(f2b_config_parse_kv_pair("=") == NULL);
assert(f2b_config_parse_kv_pair("key=") == NULL);
assert(f2b_config_parse_kv_pair("key =") == NULL);
assert(f2b_config_parse_kv_pair("key = ") == NULL);
assert(f2b_config_parse_kv_pair( "=value") == NULL);
assert(f2b_config_parse_kv_pair( "= value") == NULL);
assert(f2b_config_parse_kv_pair(" = value") == NULL);
assert((param = f2b_config_parse_kv_pair("key=value")) != NULL);
assert(strcmp(param->name, "key") == 0);
assert(strcmp(param->value, "value") == 0);
free(param);
assert((param = f2b_config_parse_kv_pair("key = value")) != NULL);
assert(strcmp(param->name, "key") == 0);
assert(strcmp(param->value, "value") == 0);
free(param);
assert((param = f2b_config_parse_kv_pair("key=value #comment")) != NULL);
assert(strcmp(param->name, "key") == 0);
assert(strcmp(param->value, "value") == 0);
free(param);
assert((param = f2b_config_parse_kv_pair("key=value#compose")) != NULL);
assert(strcmp(param->name, "key") == 0);
assert(strcmp(param->value, "value#compose") == 0);
free(param);
return 0;
}
Loading…
Cancel
Save