Skip to content

Commit

Permalink
Add unit test #2 for sol_ptr_new()
Browse files Browse the repository at this point in the history
Signed-off-by: Abhishek Chakravarti <abhishek@taranjali.org>
  • Loading branch information
achakravarti committed Feb 22, 2019
1 parent 94ca73e commit d941f9c
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions test/ptr.t.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,30 @@ static sol_erno new_01(void)



/*
* new_02() - sol_ptr_new() unit test #2
*/
static sol_erno new_02(void)
{
#define NEW_02 "sol_ptr_new() throws SOL_ERNO_PTR when passed a" \
" pointer for @ptr that has already been allocated"
auto sol_ptr *ptr = SOL_PTR_NULL;

SOL_TRY:
/* set up test scenario */
sol_assert (SOL_ERNO_NULL == sol_ptr_new(&ptr, sizeof (int)), SOL_ERNO_TEST);
sol_try (sol_ptr_new(&ptr, sizeof (int)));

SOL_CATCH:
/* check test condition */
return SOL_ERNO_PTR == sol_erno_now()
? SOL_ERNO_NULL
: SOL_ERNO_TEST;
}




/*
* __sol_tests_ptr() - declared in sol/test/suite.h
*/
Expand All @@ -74,6 +98,7 @@ extern sol_erno __sol_tests_ptr(sol_tlog *log,

/* register test cases */
sol_try (sol_tsuite_register(ts, &new_01, NEW_01));
sol_try (sol_tsuite_register(ts, &new_02, NEW_02));

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

0 comments on commit d941f9c

Please sign in to comment.