X-Git-Url: http://git.ipfire.org/?a=blobdiff_plain;f=src%2Ftest-as.c;h=a2d0ed588f037b03a268827a07978b04f335ed7e;hb=6254dca603544690c3ee71e605d560ca24d75dc3;hp=df325ba6658354103f8654e068040edb887cce7e;hpb=8b6197b85679cb6de8b6075af52c3d5706b6865f;p=location%2Flibloc.git diff --git a/src/test-as.c b/src/test-as.c index df325ba..a2d0ed5 100644 --- a/src/test-as.c +++ b/src/test-as.c @@ -34,7 +34,7 @@ int main(int argc, char** argv) { // Create a database struct loc_writer* writer; - err = loc_writer_new(ctx, &writer); + err = loc_writer_new(ctx, &writer, NULL, NULL); if (err < 0) exit(EXIT_FAILURE); @@ -49,28 +49,21 @@ int main(int argc, char** argv) { loc_as_unref(as); } - FILE* f = fopen("test.db", "w"); + FILE* f = tmpfile(); if (!f) { fprintf(stderr, "Could not open file for writing: %s\n", strerror(errno)); exit(EXIT_FAILURE); } - err = loc_writer_write(writer, f); + err = loc_writer_write(writer, f, LOC_DATABASE_VERSION_UNSET); if (err) { fprintf(stderr, "Could not write database: %s\n", strerror(-err)); exit(EXIT_FAILURE); } - fclose(f); loc_writer_unref(writer); // And open it again from disk - f = fopen("test.db", "r"); - if (!f) { - fprintf(stderr, "Could not open file for reading: %s\n", strerror(errno)); - exit(EXIT_FAILURE); - } - struct loc_database* db; err = loc_database_new(ctx, &db, f); if (err) { @@ -125,6 +118,7 @@ int main(int argc, char** argv) { loc_database_enumerator_unref(enumerator); loc_database_unref(db); loc_unref(ctx); + fclose(f); return EXIT_SUCCESS; }