/* * Copyright (C) 2006-2011 by Benedict Paten (benedictpaten@gmail.com) * * Released under the MIT license, see LICENSE.txt */ /* * sonLibTest.c * * Created on: 24 May 2010 * Author: benedictpaten */ #include "sonLibGlobalsTest.h" static stList *list = NULL; static int32_t stringNumber = 5; static char *strings[5] = { "one", "two", "three", "four", "five" }; static void teardown() { if(list != NULL) { stList_destruct(list); list = NULL; } } static void setup() { teardown(); list = stList_construct(); int32_t i; for(i=0; i=0; i--) { CuAssertTrue(testCase, stList_pop(list) == strings[i]); CuAssertTrue(testCase, stList_length(list) == i); } teardown(); } void test_stList_remove(CuTest *testCase) { setup(); CuAssertTrue(testCase, stList_remove(list, 0) == strings[0]); CuAssertTrue(testCase, stList_length(list) == stringNumber-1); CuAssertTrue(testCase, stList_remove(list, 1) == strings[2]); CuAssertTrue(testCase, stList_length(list) == stringNumber-2); teardown(); } void test_stList_removeItem(CuTest *testCase) { setup(); CuAssertTrue(testCase, stList_contains(list, strings[2])); stList_removeItem(list, strings[2]); CuAssertTrue(testCase, !stList_contains(list, strings[2])); stList_removeItem(list, strings[2]); CuAssertTrue(testCase, !stList_contains(list, strings[2])); teardown(); } void test_stList_removeFirst(CuTest *testCase) { setup(); int32_t i; for(i=0; i