Add testing for easycsv_find_num_value

Signed-off-by: Pradana AUMARS <paumars@courrier.dev>
This commit is contained in:
Pradana AUMARS 2021-07-16 23:00:05 +02:00
parent 7ce936b8d1
commit 46ed839860

View File

@ -91,6 +91,14 @@ START_TEST(test_easycsv_read_value)
str = easycsv_read_value(csv, 1, 3); str = easycsv_read_value(csv, 1, 3);
ck_assert_str_eq(str, ""); ck_assert_str_eq(str, "");
free(str); free(str);
str = easycsv_read_value(csv, 1, 4);
ck_assert_str_eq(str, "");
free(str);
str = easycsv_read_value(csv, 3, 4);
ck_assert_str_eq(str, "");
free(str);
easycsv_free(csv); easycsv_free(csv);
} }
@ -119,6 +127,19 @@ START_TEST(test_easycsv_find_value)
easycsv_free(csv); easycsv_free(csv);
} }
START_TEST(test_easycsv_find_num_value)
{
easycsv *csv = easycsv_init(SAMPLE1_PATH, EASYCSV_R);
ck_assert_int_eq(easycsv_find_num_value(csv, "FILEPATHA1"), 1);
ck_assert_int_eq(easycsv_find_num_value(csv, "FILEPATHB1"), 1);
ck_assert_int_eq(easycsv_find_num_value(csv, "FILEPATHA2"), 1);
ck_assert_int_eq(easycsv_find_num_value(csv, ""), 3);
ck_assert_int_eq(easycsv_find_num_value(csv, "NOVALUE"), 0);
easycsv_free(csv);
}
/* START_TEST(test_easycsv_readcolumnvalue) */ /* START_TEST(test_easycsv_readcolumnvalue) */
/* { */ /* { */
/* easycsv *csv = easycsv_init(SAMPLE1_PATH, EASYCSV_R); */ /* easycsv *csv = easycsv_init(SAMPLE1_PATH, EASYCSV_R); */
@ -137,6 +158,7 @@ easycsv_access_suite(void)
s = suite_create ("access"); s = suite_create ("access");
tc_find = tcase_create ("find"); tc_find = tcase_create ("find");
tcase_add_test(tc_find, test_easycsv_find_value); tcase_add_test(tc_find, test_easycsv_find_value);
tcase_add_test(tc_find, test_easycsv_find_num_value);
tc_read = tcase_create ("read"); tc_read = tcase_create ("read");
tcase_add_test(tc_read, test_easycsv_read_value); tcase_add_test(tc_read, test_easycsv_read_value);