]> git.ipfire.org Git - people/ms/libloc.git/blobdiff - src/test-stringpool.c
debian: Add script to build package for various arches
[people/ms/libloc.git] / src / test-stringpool.c
index 169554a0aa5d98e734a3d9fd8c05012105f7200c..3cde27a68fb275911be3f473eade9612987a5bc0 100644 (file)
@@ -16,6 +16,7 @@
 
 #include <stdio.h>
 #include <stddef.h>
+#include <stdint.h>
 #include <stdlib.h>
 #include <string.h>
 #include <fcntl.h>
@@ -25,7 +26,7 @@
 #include <time.h>
 
 #include <loc/libloc.h>
-#include "stringpool.h"
+#include <loc/stringpool.h>
 
 static const char* characters = "012345789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
 
@@ -55,10 +56,17 @@ int main(int argc, char** argv) {
 
        // Create the stringpool
        struct loc_stringpool* pool;
-       err = loc_stringpool_new(ctx, &pool, 10002 * 4);
+       err = loc_stringpool_new(ctx, &pool);
        if (err < 0)
                exit(EXIT_FAILURE);
 
+       // Try reading some invalid string
+       const char* s = loc_stringpool_get(pool, 100);
+       if (s != NULL) {
+               fprintf(stderr, "An unexpected string was returned: %s\n", s);
+               exit(EXIT_FAILURE);
+       }
+
        // Append a string
        off_t pos = loc_stringpool_add(pool, "ABC");
        if (pos < 0) {
@@ -66,7 +74,7 @@ int main(int argc, char** argv) {
                exit(EXIT_FAILURE);
        }
 
-       printf("Added string at %jd\n", pos);
+       printf("Added string at %jd\n", (intmax_t)pos);
 
        // Must start at first byte
        if (pos != 0) {