aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--test/main.c2
-rw-r--r--test/test_list.c33
2 files changed, 35 insertions, 0 deletions
diff --git a/test/main.c b/test/main.c
index 8f72cfc..37b5796 100644
--- a/test/main.c
+++ b/test/main.c
@@ -12,6 +12,7 @@ void test_list4();
void test_list5();
void test_list6();
void test_list7();
+void test_list8();
//void
//test_map()
@@ -32,6 +33,7 @@ int main(int argc, char** argv)
test_list5();
test_list6();
test_list7();
+ test_list8();
// test_map();
diff --git a/test/test_list.c b/test/test_list.c
index 5aa324b..d56ad6b 100644
--- a/test/test_list.c
+++ b/test/test_list.c
@@ -226,3 +226,36 @@ test_list7()
log("OK\n");
}
+
+void
+test_list8()
+{
+ log("Running...");
+
+ struct test_struct {
+ char *data;
+ };
+
+ struct test_struct *s1 = malloc(sizeof(struct test_struct *));
+ struct test_struct *s2 = malloc(sizeof(struct test_struct *));
+
+ s1->data = strdup("A long, but very long long string");
+ s2->data = strdup("Lorem ipsum");
+
+ list_t l = clist_create();
+
+ clist_add(&l, s1, sizeof(s1));
+ clist_add(&l, s2, sizeof(s2));
+
+ iterator_t it = clist_iterator(&l);
+
+ assert(clist_iterator_has_next(it));
+ assert(strcmp(((struct test_struct *) clist_iterator_next(&it))->data, "A long, but very long long string") == 0);
+
+ assert(clist_iterator_has_next(it));
+ assert(strcmp(((struct test_struct *) clist_iterator_next(&it))->data, "Lorem ipsum") == 0);
+
+ assert(clist_iterator_has_next(it) == 0);
+
+ log("OK\n");
+}