aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlessandro Iezzi <aiezzi@alessandroiezzi.it>2023-05-10 16:35:04 +0200
committerAlessandro Iezzi <aiezzi@alessandroiezzi.it>2023-05-10 16:35:04 +0200
commit204f2b9117ba34dcea1c744c9849bce009ebdd39 (patch)
treedbb5177e004a1a261438b0da4efef472028e949b
parentb6f8c43dabd4725b3a74795b85364c1a685ec6eb (diff)
downloadutils-204f2b9117ba34dcea1c744c9849bce009ebdd39.tar.gz
utils-204f2b9117ba34dcea1c744c9849bce009ebdd39.zip
Update tests with new version
-rw-r--r--test/test_list.c25
1 files changed, 16 insertions, 9 deletions
diff --git a/test/test_list.c b/test/test_list.c
index 35321d1..474a5f4 100644
--- a/test/test_list.c
+++ b/test/test_list.c
@@ -34,7 +34,7 @@ test_list1()
const char *data = "hello";
list_t list = clist_create();
- clist_add(&list, (void *) data);
+ clist_add(&list, (void *) data, strlen(data) * sizeof(char));
assert(list.first == list.last);
assert(strcmp(list.first->data, data) == 0);
@@ -52,7 +52,7 @@ test_list2()
char *data1 = strdup("hello");
list_t list = clist_create();
- clist_add(&list, data1);
+ clist_add(&list, data1, strlen(data1) * sizeof(char));
iterator_t it = clist_iterator(&list);
assert(clist_iterator_has_next(it));
@@ -75,8 +75,11 @@ test_list3()
list_t l1 = clist_create();
list_t l2 = clist_create();
- clist_add(&l1, "test1");
- clist_add(&l2, "test2");
+ char *str1 = "test1";
+ char *str2 = "test2";
+
+ clist_add(&l1, str1, strlen(str1) * sizeof(char));
+ clist_add(&l2, str2, strlen(str2) * sizeof(char));
clist_add_all(&l1, &l2);
@@ -101,12 +104,16 @@ test_list4()
list_t l1 = clist_create();
list_t l2 = clist_create();
- clist_add(&l1, "test1");
- clist_add(&l2, "test2");
+ char *s1 = "test1";
+ char *s2 = "test2";
+ char *s3 = "test3";
+
+ clist_add(&l1, s1, strlen(s1) * sizeof(char));
+ clist_add(&l2, s2, strlen(s2) * sizeof(char));
clist_add_all(&l1, &l2);
/* add a new element */
- clist_add(&l1, "test3");
+ clist_add(&l1, s3, strlen(s3) * sizeof(char));
iterator_t i = clist_iterator(&l1);
if (clist_iterator_has_next(i))
@@ -140,14 +147,14 @@ list_item_t *r;
sprintf(buffer, "%d", i);
strcpy(dest, "i");
strcat(dest, buffer);
- clist_add(&list1, dest);
+ clist_add(&list1, dest, strlen(dest) * sizeof(char));
}
for (int i = 0; i < 5; i++) {
sprintf(buffer, "%d", i);
strcpy(dest, "j");
strcat(dest, buffer);
- clist_add(&list2, dest);
+ clist_add(&list2, dest, strlen(dest) * sizeof(char));
if (i == 3) r = list2.last;
}