Skip to content

Commit

Permalink
Add unit test #2 for sol_list_nref
Browse files Browse the repository at this point in the history
Signed-off-by: Abhishek Chakravarti <abhishek@taranjali.org>
  • Loading branch information
achakravarti committed Jul 17, 2019
1 parent ee62243 commit 416789f
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions test/ts-list.c
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,32 @@ static sol_erno nref_test1(void)



/* define the unit test to run the test case described by NREF_TEST2 */
static sol_erno nref_test2(void)
{
#define NREF_TEST2 "sol_list_nref() throws SOL_ERNO_PTR if passed a" \
" null pointer for @list"

auto sol_size nref;

SOL_TRY:
/* set up test */
sol_try (sol_list_nref(SOL_PTR_NULL, &nref));

SOL_CATCH:
/* check test condition */
sol_erno_set(sol_erno_get() == SOL_ERNO_PTR
? SOL_ERNO_NULL
: SOL_ERNO_TEST);

SOL_FINALLY:
/* wind up */
return sol_erno_get();
}




/* __sol_tests_list() is declared in sol/test/suite.h */
extern sol_erno __sol_tests_list(sol_tlog *log,
sol_uint *pass,
Expand Down Expand Up @@ -443,6 +469,7 @@ extern sol_erno __sol_tests_list(sol_tlog *log,

/* register sol_list_nref() test cases */
sol_try (sol_tsuite_register(hnd, nref_test1, NREF_TEST1));
sol_try (sol_tsuite_register(hnd, nref_test2, NREF_TEST2));

/* execute test cases */
sol_try (sol_tsuite_exec(hnd));
Expand Down

0 comments on commit 416789f

Please sign in to comment.