|
|
|
@ -4,28 +4,59 @@
|
|
|
|
|
static const char SAMPLE1_PATH[] = "samples/1.csv"; |
|
|
|
|
static const char SAMPLE2_PATH[] = "samples/2.csv"; |
|
|
|
|
|
|
|
|
|
START_TEST(test_easycsv_init_read) |
|
|
|
|
START_TEST(test_easycsv_init_read_1) |
|
|
|
|
{ |
|
|
|
|
easycsv *csv = NULL; |
|
|
|
|
csv = easycsv_init(SAMPLE1_PATH, EASYCSV_R); |
|
|
|
|
ck_assert_ptr_nonnull(csv); |
|
|
|
|
easycsv_free(csv); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
START_TEST(test_easycsv_init_read_2) |
|
|
|
|
{ |
|
|
|
|
easycsv *csv = NULL; |
|
|
|
|
csv = easycsv_init(SAMPLE2_PATH, EASYCSV_R); |
|
|
|
|
ck_assert_ptr_nonnull(csv); |
|
|
|
|
ck_assert_ptr_null(csv); |
|
|
|
|
easycsv_free(csv); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
START_TEST(test_easycsv_init_write) |
|
|
|
|
START_TEST(test_easycsv_init_write_1) |
|
|
|
|
{ |
|
|
|
|
easycsv *csv = NULL; |
|
|
|
|
csv = easycsv_init(SAMPLE1_PATH, EASYCSV_W); |
|
|
|
|
ck_assert_ptr_nonnull(csv); |
|
|
|
|
easycsv_free(csv); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
START_TEST(test_easycsv_init_write_2) |
|
|
|
|
{ |
|
|
|
|
easycsv *csv = NULL; |
|
|
|
|
csv = easycsv_init(SAMPLE2_PATH, EASYCSV_W); |
|
|
|
|
ck_assert_ptr_nonnull(csv); |
|
|
|
|
easycsv_free(csv); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Suite* |
|
|
|
|
easycsv_constructor_suite(void) |
|
|
|
|
{ |
|
|
|
|
Suite *s; |
|
|
|
|
TCase *tc_read, *tc_write; |
|
|
|
|
|
|
|
|
|
s = suite_create ("constructor"); |
|
|
|
|
tc_read = tcase_create ("read mode"); |
|
|
|
|
tc_write = tcase_create ("write mode"); |
|
|
|
|
|
|
|
|
|
tcase_add_test(tc_read, test_easycsv_init_read_1); |
|
|
|
|
tcase_add_test(tc_read, test_easycsv_init_read_2); |
|
|
|
|
tcase_add_test(tc_write, test_easycsv_init_write_1); |
|
|
|
|
tcase_add_test(tc_write, test_easycsv_init_write_2); |
|
|
|
|
|
|
|
|
|
suite_add_tcase(s, tc_read); |
|
|
|
|
//suite_add_tcase(s, tc_write);
|
|
|
|
|
|
|
|
|
|
return s; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
START_TEST(test_easycsv_printcolumns) |
|
|
|
|
{ |
|
|
|
|
easycsv *csv = easycsv_init(SAMPLE1_PATH, EASYCSV_R); |
|
|
|
@ -51,49 +82,27 @@ START_TEST(test_easycsv_readcolumnvalue)
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Suite* |
|
|
|
|
easycsv_constructor_suite(void) |
|
|
|
|
{ |
|
|
|
|
Suite *s; |
|
|
|
|
TCase *tc_init; |
|
|
|
|
|
|
|
|
|
s = suite_create ("constructor"); |
|
|
|
|
tc_init = tcase_create ("basic constructor"); |
|
|
|
|
|
|
|
|
|
tcase_add_test(tc_init, test_easycsv_init_read); |
|
|
|
|
tcase_add_test(tc_init, test_easycsv_init_write); |
|
|
|
|
suite_add_tcase(s, tc_init); |
|
|
|
|
|
|
|
|
|
return s; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Suite* |
|
|
|
|
easycsv_print_suite(void) |
|
|
|
|
easycsv_read_suite(void) |
|
|
|
|
{ |
|
|
|
|
Suite *s; |
|
|
|
|
TCase *tc_col, *tc_row; |
|
|
|
|
s = suite_create ("print"); |
|
|
|
|
TCase *tc_readcolumnvalue, *tc_col, *tc_row; |
|
|
|
|
s = suite_create ("read"); |
|
|
|
|
tc_readcolumnvalue = tcase_create ("readcolumnvalue"); |
|
|
|
|
tcase_add_test(tc_readcolumnvalue, test_easycsv_readcolumnvalue); |
|
|
|
|
|
|
|
|
|
tc_col = tcase_create ("columns"); |
|
|
|
|
tc_row = tcase_create ("rows"); |
|
|
|
|
tcase_add_test(tc_col, test_easycsv_printcolumns); |
|
|
|
|
|
|
|
|
|
tc_row = tcase_create ("rows"); |
|
|
|
|
tcase_add_test(tc_row, test_easycsv_printrows); |
|
|
|
|
|
|
|
|
|
suite_add_tcase(s, tc_readcolumnvalue); |
|
|
|
|
suite_add_tcase(s, tc_col); |
|
|
|
|
suite_add_tcase(s, tc_row); |
|
|
|
|
|
|
|
|
|
return s; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Suite* |
|
|
|
|
easycsv_read_suite(void) |
|
|
|
|
{ |
|
|
|
|
Suite *s; |
|
|
|
|
TCase *tc_readcolumnvalue; |
|
|
|
|
s = suite_create ("read"); |
|
|
|
|
tc_readcolumnvalue = tcase_create ("readcolumnvalue"); |
|
|
|
|
tcase_add_test(tc_readcolumnvalue, test_easycsv_readcolumnvalue); |
|
|
|
|
|
|
|
|
|
return s; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
int |
|
|
|
|
main(void) |
|
|
|
|
{ |
|
|
|
@ -101,7 +110,6 @@ main(void)
|
|
|
|
|
SRunner *sr; |
|
|
|
|
|
|
|
|
|
sr = srunner_create(easycsv_constructor_suite()); |
|
|
|
|
srunner_add_suite(sr, easycsv_print_suite()); |
|
|
|
|
srunner_add_suite(sr, easycsv_read_suite()); |
|
|
|
|
|
|
|
|
|
srunner_run_all(sr, CK_VERBOSE); |
|
|
|
|