#include "test.h" #include "codec/codec_ttl.h" #define TERM_CT 10 #define W3C_POS_TEST_CT 30 #define W3C_NEG_TEST_CT 14 #define W3C_TEST_BASE "http://www.w3.org/2001/sw/DataAccess/df1/tests/" /// Positive test suite from W3C. int test_w3c_pos() { char test_fname[36], out_fname[36]; LSUP_Graph *gr; size_t ct; char *err; char ch; for (int i = 0; i <= W3C_POS_TEST_CT; i++) { #if 1 // Tests 14รท16 with 10K triples is quite long. Skip them temporarily. // TODO use a switch based on env var. if (i > 12 && i <17) continue; #endif size_t nt_ct = 0; sprintf (test_fname, "test/assets/ttl/test-%02d.ttl", i); sprintf (out_fname, "test/assets/ttl/test-%02d.out", i); FILE *test_stream = fopen (test_fname, "r"); FILE *out_stream = fopen (out_fname, "r"); log_info ("Testing %s", test_fname); while ((ch=fgetc (out_stream)) != EOF) { if (ch == '\n') nt_ct++; } EXPECT_PASS (codec.decode_graph (test_stream, &gr, &ct, &err)); EXPECT_INT_EQ (LSUP_graph_size (gr), nt_ct); // Just count NT lines. } return 0; } /// Negative test suite from W3C. int test_w3c_neg() { return 0; } int codec_ttl_tests() { LSUP_Term **terms = init_terms(); init_triples (terms); codec = ttl_codec; //RUN (test_encode_ttl_graph); //RUN (test_decode_ttl_graph); //RUN (test_decode_ttl_bad_graph); RUN (test_w3c_pos); //RUN (test_w3c_neg); free_terms(terms); return 0; }