Example #1
0
void test_pop(void) {
	Stack s = NULL;
	Stack scomp;
	char* a = "sdfghjklm";
	char* b = "azerty";
	char* res;
	S_push(&s, a);
	scomp = s;
	S_push(&s, b);
	res = (char*)S_pop(&s);
	CU_ASSERT_STRING_EQUAL(res, b);
	CU_ASSERT_PTR_EQUAL(s, scomp);
	res = (char*)S_pop(&s);
	CU_ASSERT_STRING_EQUAL(res, a);
	CU_ASSERT_PTR_EQUAL(s, NULL);
}
Example #2
0
void S_free(STACK* S)
{
  assert( S != NULL );

  while( ! S_empty(S) )
    {
    S_pop(S);
    }
  deallocate(S);
}