Add test for calibrate.replace_text
This commit is contained in:
parent
f9f8ce747a
commit
24ac0e4897
@ -5,9 +5,10 @@ noinst_PROGRAMS = \
|
||||
check_check
|
||||
|
||||
check_check_SOURCES = \
|
||||
check_check.c \
|
||||
check_file_t.c \
|
||||
check_exception_t.c \
|
||||
check_check.c
|
||||
check_calibrate.c
|
||||
check_check_CFLAGS= $(CFLAGS) $(CHECK_CFLAGS)
|
||||
check_check_LDFLAGS= $(LDFLAGS) $(CHECK_LIBS)
|
||||
check_check_LDADD = $(top_builddir)/src/libmodetw.la
|
||||
|
@ -1,8 +1,36 @@
|
||||
#include <stdlib.h>
|
||||
#include <check.h>
|
||||
|
||||
#include "check_check.h"
|
||||
#include "../src/calibrate.h"
|
||||
#include "../src/file_t.h"
|
||||
|
||||
START_TEST(test_calibrate)
|
||||
START_TEST(test_replace_text)
|
||||
{
|
||||
|
||||
exception_t *e;
|
||||
file_t *f;
|
||||
e = exception_init();
|
||||
f = file_init("samples/1.txt", FILEPATH_RELATIVE, e);
|
||||
char *path = file_abs(f);
|
||||
ck_assert(replace_text(path, "ABC", "123", "ASCII", e));
|
||||
ck_assert(exception_null(e));
|
||||
ck_assert(replace_text(path, "123", "ABC", "ASCII", e));
|
||||
ck_assert(exception_null(e));
|
||||
file_close(f);
|
||||
exception_free(e);
|
||||
free(path);
|
||||
}
|
||||
|
||||
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);
|
||||
suite_add_tcase(s, tc_core);
|
||||
|
||||
return s;
|
||||
}
|
||||
|
@ -9,6 +9,7 @@ main(void)
|
||||
|
||||
sr = srunner_create(file_t_suite());
|
||||
srunner_add_suite(sr, exception_t_suite());
|
||||
srunner_add_suite(sr, calibrate_suite());
|
||||
|
||||
srunner_run_all(sr, CK_VERBOSE);
|
||||
number_failed = srunner_ntests_failed(sr);
|
||||
|
@ -5,5 +5,6 @@
|
||||
|
||||
Suite* file_t_suite(void);
|
||||
Suite* exception_t_suite(void);
|
||||
Suite* calibrate_suite(void);
|
||||
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user