]> git.lizzy.rs Git - dragonstd.git/commitdiff
Use proper format for size_t printf
authorElias Fleckenstein <eliasfleckenstein@web.de>
Sun, 24 Apr 2022 15:01:42 +0000 (17:01 +0200)
committerElias Fleckenstein <eliasfleckenstein@web.de>
Sun, 24 Apr 2022 15:01:42 +0000 (17:01 +0200)
test/test_array.c

index a6c8e19fa87fe345e6e6c7a5b3761791937eb6de..db10964f615c9dd751162bd9a3fb584cd7a1a19f 100644 (file)
@@ -47,10 +47,10 @@ int main()
        i = 2; array_put(&arr, &i, 1);
        i = 5; array_put(&arr, &i, arr.siz);
 
-       printf("testing siz: exp: 5 got: %lu\n", arr.siz);
+       printf("testing siz: exp: 5 got: %zu\n", arr.siz);
        assert(arr.siz == 5);
 
-       printf("testing cap: exp: 5 got: %lu\n", arr.cap);
+       printf("testing cap: exp: 5 got: %zu\n", arr.cap);
        assert(arr.cap == 5);
 
        printf("testing contents: exp: 1,2,3,4,5 got: "); dump(&arr); printf("\n");
@@ -73,44 +73,44 @@ int main()
        printf("testing ini after clr\n");
        array_ini(&arr, sizeof(int), 5);
 
-       printf("testing cap: exp: 0 got: %lu\n", arr.cap);
+       printf("testing cap: exp: 0 got: %zu\n", arr.cap);
        assert(arr.cap == 0);
 
        printf("testing overallocation\n");
        i = 50; array_apd(&arr, &i);
 
-       printf("testing cap: exp: 0 got: %lu\n", arr.cap);
+       printf("testing cap: exp: 0 got: %zu\n", arr.cap);
        assert(arr.siz == 1);
 
-       printf("testing cap: exp: 6 got: %lu\n", arr.cap);
+       printf("testing cap: exp: 6 got: %zu\n", arr.cap);
        assert(arr.cap == 6);
 
        for (int j = 0; j < 7; j++) {
                i = rand() % 100; array_apd(&arr, &i);
        }
 
-       printf("testing siz: exp: 8 got: %lu\n", arr.cap);
+       printf("testing siz: exp: 8 got: %zu\n", arr.cap);
        assert(arr.siz == 8);
 
-       printf("testing cap: exp: 12 got: %lu\n", arr.cap);
+       printf("testing cap: exp: 12 got: %zu\n", arr.cap);
        assert(arr.cap == 12);
 
        printf("testing grw\n");
        array_grw(&arr, 5);
 
-       printf("testing siz: exp: 13 got: %lu\n", arr.cap);
+       printf("testing siz: exp: 13 got: %zu\n", arr.cap);
        assert(arr.siz == 13);
 
-       printf("testing cap: exp: 18 got: %lu\n", arr.cap);
+       printf("testing cap: exp: 18 got: %zu\n", arr.cap);
        assert(arr.cap == 18);
 
        printf("testing shr\n");
        array_shr(&arr, 5);
 
-       printf("testing siz: exp: 8 got: %lu\n", arr.cap);
+       printf("testing siz: exp: 8 got: %zu\n", arr.cap);
        assert(arr.siz == 8);
 
-       printf("testing cap: exp: 8 got: %lu\n", arr.cap);
+       printf("testing cap: exp: 8 got: %zu\n", arr.cap);
        assert(arr.cap == 8);
 
        printf("testing srt\n");
@@ -123,12 +123,12 @@ int main()
                i = ((int *) arr.ptr)[j];
                ssize_t s = array_fnd(&arr, &i, NULL, &cmp_int);
 
-               printf("testing fnd at index %lu: exp: >=0 got: %ld\n", j, s);
+               printf("testing fnd at index %zu: exp: >=0 got: %ld\n", j, s);
                assert(s >= 0);
 
                int k = ((int *) arr.ptr)[s];
 
-               printf("testing fnd at index %lu: exp: %d got: %d\n", j, i, k);
+               printf("testing fnd at index %zu: exp: %d got: %d\n", j, i, k);
                assert(k == i);
        }