#include #include #include #include "check_check.h" #include "../src/calibrate.h" #include "../src/file_t.h" START_TEST(test_replace_text) { exception_t *e; file_t *f; char except_msg[CHAR_MAX]; e = exception_init(); f = file_init("samples/1.txt", FILEPATH_RELATIVE, e); ck_assert_msg(exception_null(e), exception_str(e, except_msg)); replace_text(f->name, "ABC", "123", "ASCII", e); ck_assert_msg(exception_null(e), exception_str(e, except_msg)); replace_text(f->name, "123", "ABC", "ASCII", e); ck_assert_msg(exception_null(e), exception_str(e, except_msg)); file_close(f); exception_free(e); } START_TEST(test_parse_group) { exception_t *e; char except_msg[CHAR_MAX]; e = exception_init(); xmlDoc *doc = xmlReadFile("samples/1.xml", NULL, 0); xmlNode *cur_node = xmlDocGetRootElement (doc); while (cur_node != NULL) { if (cur_node->type == XML_ELEMENT_NODE && xmlStrEqual(cur_node->name, (const xmlChar*) "group")) { parse_group(cur_node, e); ck_assert_msg(exception_null(e), exception_str(e, except_msg)); } cur_node = cur_node->next; } ck_assert_msg(exception_null(e), exception_str(e, except_msg)); exception_free(e); } START_TEST(test_verify) { exception_t *e; char except_msg[CHAR_MAX]; e = exception_init(); verify(e); ck_assert_msg(exception_null(e), exception_str(e, except_msg)); exception_free(e); } Suite* calibrate_suite(void) { Suite *s; TCase *tc_core; s = suite_create ("calibrate"); tc_core = tcase_create ("core"); tcase_add_test(tc_core, test_replace_text); tcase_add_test(tc_core, test_parse_group); tcase_add_test(tc_core, test_verify); suite_add_tcase(s, tc_core); return s; }