Add easycsv_string testing

Signed-off-by: Pradana AUMARS <paumars@courrier.dev>
This commit is contained in:
Pradana AUMARS 2021-07-17 18:23:30 +02:00
parent 9cdf20e7a7
commit 9ac6ee03e4
2 changed files with 45 additions and 2 deletions

View File

@ -1,11 +1,19 @@
TESTS = \ TESTS = \
check_easycsv check_easycsv \
check_easycsv_string
noinst_PROGRAMS = \ noinst_PROGRAMS = \
check_easycsv check_easycsv \
check_easycsv_string
check_easycsv_SOURCES = \ check_easycsv_SOURCES = \
check_easycsv.c check_easycsv.c
check_easycsv_CFLAGS = $(CHECK_CFLAGS) check_easycsv_CFLAGS = $(CHECK_CFLAGS)
check_easycsv_LDFLAGS = $(CHECK_LIBS) check_easycsv_LDFLAGS = $(CHECK_LIBS)
check_easycsv_LDADD = $(top_builddir)/src/libeasycsv.la check_easycsv_LDADD = $(top_builddir)/src/libeasycsv.la
check_easycsv_string_SOURCES = \
check_easycsv_string.c
check_easycsv_string_CFLAGS = $(CHECK_CFLAGS)
check_easycsv_string_LDFLAGS = $(CHECK_LIBS)
check_easycsv_string_LDADD = $(top_builddir)/src/libeasycsv_string.la

View File

@ -0,0 +1,35 @@
#include <check.h>
#include "../src/easycsv_string.h"
START_TEST(test_easycsv_set_charp_to_value)
{
const char* str1 = "test,test,test,test";
char* c;
c = easycsv_set_charp_to_value(str1, 1);
ck_assert_ptr_eq(c, &str1[0]);
c = easycsv_set_charp_to_value(str1, 2);
ck_assert_ptr_eq(c, &str1[5]);
}
int
main(void)
{
int number_failed;
SRunner *sr;
Suite *s;
TCase *tc_string;
s = suite_create("string manipulation");
tc_string = tcase_create("string");
tcase_add_test(tc_string, test_easycsv_set_charp_to_value);
suite_add_tcase(s, tc_string);
sr = srunner_create(s);
srunner_run_all(sr, CK_VERBOSE);
number_failed = srunner_ntests_failed(sr);
srunner_free(sr);
return number_failed;
}