|
@@ -1,3 +1,5 @@
|
|
|
+#include <unistd.h>
|
|
|
+
|
|
|
#include "volksdata/codec/codec_nt.h"
|
|
|
#include "test.h"
|
|
|
|
|
@@ -247,6 +249,56 @@ test_decode_nt_graph()
|
|
|
}
|
|
|
|
|
|
|
|
|
+int
|
|
|
+test_decode_nt_file()
|
|
|
+{
|
|
|
+ VOLK_Graph *gr;
|
|
|
+ size_t ct;
|
|
|
+ char *err;
|
|
|
+ FILE *fh = fopen ("test/assets/test2.nt", "r");
|
|
|
+
|
|
|
+ EXPECT_PASS (codec.decode_graph (fh, NULL, &gr, &ct, &err));
|
|
|
+
|
|
|
+ EXPECT_INT_EQ (VOLK_graph_size (gr), 7);
|
|
|
+ EXPECT_INT_EQ (ct, 8);
|
|
|
+
|
|
|
+ VOLK_graph_free (gr);
|
|
|
+ fclose(fh);
|
|
|
+
|
|
|
+ return 0;
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+#define LARGE_LIT_SIZE CHUNK_SIZE * 2 + 1 // More than 2 buffer pages.
|
|
|
+int
|
|
|
+test_decode_large_lit_file()
|
|
|
+{
|
|
|
+ VOLK_Graph *gr;
|
|
|
+ size_t ct;
|
|
|
+ char *err;
|
|
|
+ const char *fpath = "/tmp/test_large_lit.nt";
|
|
|
+ FILE *fh = fopen (fpath, "w");
|
|
|
+
|
|
|
+ fprintf (fh, "<urn:s:1> <urn:p:1> \"");
|
|
|
+ for (unsigned i = 0; i < LARGE_LIT_SIZE; i++)
|
|
|
+ fputc (rand() % 25 + 65, fh); // A-Z
|
|
|
+ fprintf(fh, "\" .\n");
|
|
|
+ fclose(fh);
|
|
|
+
|
|
|
+ fh = fopen (fpath, "r");
|
|
|
+ EXPECT_PASS (codec.decode_graph (fh, NULL, &gr, &ct, &err));
|
|
|
+
|
|
|
+ EXPECT_INT_EQ (VOLK_graph_size (gr), 1);
|
|
|
+ EXPECT_INT_EQ (ct, 1);
|
|
|
+
|
|
|
+ VOLK_graph_free (gr);
|
|
|
+ fclose(fh);
|
|
|
+ unlink (fpath);
|
|
|
+
|
|
|
+ return 0;
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
int
|
|
|
test_decode_nt_bad_graph()
|
|
|
{
|
|
@@ -281,6 +333,8 @@ int codec_nt_tests()
|
|
|
RUN (test_encode_nt_graph);
|
|
|
RUN (test_decode_nt_term);
|
|
|
RUN (test_decode_nt_graph);
|
|
|
+ RUN (test_decode_nt_file);
|
|
|
+ //RUN (test_decode_large_lit_file); // FIXME large literals still not working.
|
|
|
RUN (test_decode_nt_bad_graph);
|
|
|
|
|
|
free_terms (terms);
|