From 9ac6ee03e4aaf0f34913745374ca99af2609eb51 Mon Sep 17 00:00:00 2001 From: Pradana AUMARS Date: Sat, 17 Jul 2021 18:23:30 +0200 Subject: [PATCH] Add easycsv_string testing Signed-off-by: Pradana AUMARS --- tests/Makefile.am | 12 ++++++++++-- tests/check_easycsv_string.c | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+), 2 deletions(-) create mode 100644 tests/check_easycsv_string.c diff --git a/tests/Makefile.am b/tests/Makefile.am index c02c830..812fbd8 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -1,11 +1,19 @@ TESTS = \ - check_easycsv + check_easycsv \ + check_easycsv_string noinst_PROGRAMS = \ - check_easycsv + check_easycsv \ + check_easycsv_string check_easycsv_SOURCES = \ check_easycsv.c check_easycsv_CFLAGS = $(CHECK_CFLAGS) check_easycsv_LDFLAGS = $(CHECK_LIBS) 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 diff --git a/tests/check_easycsv_string.c b/tests/check_easycsv_string.c new file mode 100644 index 0000000..adc6d13 --- /dev/null +++ b/tests/check_easycsv_string.c @@ -0,0 +1,35 @@ +#include +#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; +} +