43 lines
831 B
C++
43 lines
831 B
C++
#include <unity.h>
|
|
#include "utils.h"
|
|
|
|
void setUp(void) {
|
|
// set stuff up here
|
|
}
|
|
|
|
void tearDown(void) {
|
|
// clean stuff up here
|
|
}
|
|
|
|
void test_add(void) {
|
|
List<int> list;
|
|
int value = 10;
|
|
list.add(&value);
|
|
TEST_ASSERT_EQUAL(value, *list.last->t);
|
|
TEST_ASSERT_EQUAL_PTR(list.first, list.last);
|
|
|
|
int value2 = 12;
|
|
list.add(&value2);
|
|
TEST_ASSERT_EQUAL(value2, *list.last->t);
|
|
TEST_ASSERT_EQUAL_PTR(list.first->next, list.last);
|
|
}
|
|
|
|
void test_empty(void) {
|
|
List<int> list;
|
|
int value = 10;
|
|
list.add(&value);
|
|
list.add(&value);
|
|
list.empty();
|
|
TEST_ASSERT_EQUAL_PTR(nullptr, list.first);
|
|
TEST_ASSERT_EQUAL_PTR(list.first, list.last);
|
|
}
|
|
|
|
int main(int argc, char **argv) {
|
|
UNITY_BEGIN();
|
|
RUN_TEST(test_add);
|
|
RUN_TEST(test_empty);
|
|
UNITY_END();
|
|
|
|
return 0;
|
|
}
|