Browse Source

* tests for check_config()

master
Alex 'AdUser' Z 9 years ago
parent
commit
9c891577be
  1. 3
      tests/CMakeLists.txt
  2. 28
      tests/check_config.c

3
tests/CMakeLists.txt

@ -4,3 +4,6 @@ set(SRC_DIR "../src")
add_executable("parse_config" "${SRC_DIR}/config.c" "parse_config.c") add_executable("parse_config" "${SRC_DIR}/config.c" "parse_config.c")
add_test("parse_config" "parse_config") add_test("parse_config" "parse_config")
add_executable("check_config" "${SRC_DIR}/config.c" "check_config.c")
add_test("check_config" "check_config")

28
tests/check_config.c

@ -0,0 +1,28 @@
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "../src/config.h"
#define STEAL(attr) \
stealed = config.attr, config.attr = NULL, config.error = NULL; \
assert(check_config(&config) > 0); \
assert(config.error != NULL); \
config.attr = stealed
int main(void) {
char *stealed = NULL;
oal_config_t config;
memset(&config, 0x0, sizeof(oal_config_t));
assert(parse_config(&config, "test.conf") == 0);
STEAL(bindpass);
STEAL(userfilter);
STEAL(basedn);
STEAL(bindurls);
return 0;
}
Loading…
Cancel
Save