From f3be9dc13cf255844b825fa106e57d42f99715d0 Mon Sep 17 00:00:00 2001 From: xavi Date: Sun, 15 Sep 2024 10:58:41 -0700 Subject: [PATCH] Added test for display_task_lists --- tests/tests.c | 35 +++++++++++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) diff --git a/tests/tests.c b/tests/tests.c index 40f155b..f826225 100644 --- a/tests/tests.c +++ b/tests/tests.c @@ -1,5 +1,6 @@ #include #include +#include // printf Formating #define X_RED "\x1B[31m" @@ -14,7 +15,7 @@ // SET THE NUMBER OF TESTS -#define NUM_TESTS 5 +#define NUM_TESTS 6 // DEFINE REUSABLE TEST SETUPS int set_up_db(sqlite3 **db){ @@ -99,11 +100,40 @@ int test_add_then_update_task_status_then_delete(){ return 0; } +int test_display_task(){ + printf("%s... ", __func__); + FILE *fd1; + FILE *stdout_org; + sqlite3 *db; + int rc = 0; + + if ( (rc = set_up_db(&db)) ){ + return rc; + } + + stdout_org = stdout; + + errno = 0; + fd1 = fopen("/dev/null", "w"); + if(fd1 == NULL){ + return -1; + } + + stdout = fd1; + if ( (rc = view_tasks(db)) ){ + return rc; + } + + stdout = stdout_org; + fclose(fd1); + return 0; +} + int test_update_task(){ printf("%s... ", __func__); int rc = 0; sqlite3 *db; - + } // DUMMY TEST @@ -142,6 +172,7 @@ int main(){ tests[2] = test_del_task; tests[3] = test_add_new_task_with_date_and_delete; tests[4] = test_add_then_update_task_status_then_delete; + tests[5] = test_display_task; // END OF PASSING TESTS