From 49ab48d80c31b960b980a371d9647a62242f6837 Mon Sep 17 00:00:00 2001 From: Abhishek Chakravarti Date: Wed, 6 Feb 2019 11:29:28 +0530 Subject: [PATCH] Add unit test #2 for sol_tsuite_total() Signed-off-by: Abhishek Chakravarti --- test/test.t.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/test/test.t.c b/test/test.t.c index 58d307d..41d1fbc 100644 --- a/test/test.t.c +++ b/test/test.t.c @@ -138,6 +138,15 @@ +/* + * DESC_TOTAL_02 - description for sol_tsuite_total() unit test #2 + */ +#define DESC_TOTAL_02 "sol_tsuite_total() should throw SOL_ERNO_PTR when" \ + " passed a null pointer for @total" + + + + /* * tlog_dummy() - dummy test suite logging callback */ @@ -423,6 +432,29 @@ test_total_01(void) +/* + * test_total_02() - sol_tsuite_total() unit test #2 + */ +static sol_erno +test_total_02(void) +{ + auto sol_tsuite ts; /* dummy test suite */ + +SOL_TRY: + /* sol_tsuite_fail() should fail with SOL_ERNO_PTR */ + sol_try (sol_tsuite_init2 (&ts, tlog_dummy)); + sol_try (sol_tsuite_total (&ts, 0)); + +SOL_CATCH: + /* check test condition described by DESC_TOTAL_02 */ + return SOL_ERNO_PTR == sol_erno_now () + ? SOL_ERNO_NULL + : SOL_ERNO_TEST; +} + + + + /* * __sol_tsuite_test() - declared in sol/test/suite.h */ @@ -455,6 +487,7 @@ __sol_tsuite_test(sol_tlog *log, sol_try (sol_tsuite_register (ts, test_fail_01, DESC_FAIL_01)); sol_try (sol_tsuite_register (ts, test_fail_02, DESC_FAIL_02)); sol_try (sol_tsuite_register (ts, test_total_01, DESC_TOTAL_01)); + sol_try (sol_tsuite_register (ts, test_total_02, DESC_TOTAL_02)); /* execute test cases */ sol_try (sol_tsuite_exec (ts));