test_desc.c 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. #include "test.h"
  2. #include "namespace.h"
  3. static int
  4. test_desc_create()
  5. {
  6. /*
  7. LSUP_Term *terms1[] = {
  8. LSUP_iriref_new ("urn:s:1", NULL),
  9. LSUP_iriref_new ("urn:s:2", NULL),
  10. LSUP_iriref_new ("urn:p:1", NULL),
  11. LSUP_iriref_new ("urn:p:2", NULL),
  12. LSUP_iriref_new ("urn:o:1", NULL),
  13. LSUP_iriref_new ("urn:o:2", NULL),
  14. };
  15. LSUP_Term *terms2[] = {
  16. LSUP_iriref_new ("urn:s:10", NULL),
  17. LSUP_iriref_new ("urn:s:20", NULL),
  18. LSUP_iriref_new ("urn:p:10", NULL),
  19. LSUP_iriref_new ("urn:p:20", NULL),
  20. LSUP_iriref_new ("urn:o:10", NULL),
  21. LSUP_iriref_new ("urn:o:20", NULL),
  22. };
  23. LSUP_Triple *trp1[] = {
  24. LSUP_triple_new (terms1[0], terms1[2], terms1[4]),
  25. LSUP_triple_new (terms1[0], terms1[3], terms1[4]),
  26. LSUP_triple_new (terms1[0], terms1[3], terms1[5]),
  27. LSUP_triple_new (terms1[1], terms1[2], terms1[4]),
  28. NULL
  29. };
  30. LSUP_Triple *trp2[] = {
  31. LSUP_triple_new (terms2[0], terms2[2], terms2[4]),
  32. LSUP_triple_new (terms2[0], terms2[3], terms2[4]),
  33. LSUP_triple_new (terms2[0], terms2[3], terms2[5]),
  34. LSUP_triple_new (terms2[1], terms2[2], terms2[4]),
  35. NULL
  36. };
  37. LSUP_Term *usr1_uri = LSUP_iriref_new ("#usr1", NULL);
  38. LSUP_Graph *gr1 = LSUP_graph_new (NULL, usr1_uri, NULL);
  39. LSUP_term_free (usr1_uri);
  40. ASSERT (gr1, "Error creating graph!");
  41. EXPECT_PASS (LSUP_graph_add (gr1, trp1, NULL));
  42. for (size_t i = 0; trp1[i]; i++)
  43. free (trp1[i]);
  44. LSUP_Term *usr2_uri = LSUP_iriref_new ("#usr2", NULL);
  45. LSUP_Graph *gr2 = LSUP_graph_new (NULL, usr2_uri, NULL);
  46. LSUP_term_free (usr2_uri);
  47. ASSERT (gr2, "Error creating graph!");
  48. EXPECT_PASS (LSUP_graph_add (gr2, trp2, NULL));
  49. char *tmp = NULL;
  50. void *it;
  51. it = ttl_codec.encode_graph_init(gr1);
  52. while (ttl_codec.encode_graph_iter (it, &tmp) != LSUP_END)
  53. log_info ("gr1: %s\n", tmp);
  54. ttl_codec.encode_graph_done (it);
  55. it = ttl_codec.encode_graph_init(gr2);
  56. while (ttl_codec.encode_graph_iter (it, &tmp) != LSUP_END)
  57. log_info ("gr2: %s\n", tmp);
  58. ttl_codec.encode_graph_done (it);
  59. free (tmp);
  60. for (size_t i = 0; trp2[i]; i++)
  61. free (trp2[i]);
  62. */
  63. char
  64. *ttl1 = "<urn:s:1> <urn:p:2> <urn:o:2> , <urn:o:1> ; "
  65. "<urn:p:1> <urn:o:1> . "
  66. "<urn:s:2> <urn:p:1> <urn:o:1> . ",
  67. *ttl2 = "<urn:s:20> <urn:p:10> <urn:o:10> . "
  68. "<urn:s:10> <urn:p:10> <urn:o:10> ; "
  69. "<urn:p:20> <urn:o:20> , <urn:o:10> . ";
  70. LSUP_Term
  71. *usr1_uri = LSUP_iriref_new ("#usr1", NULL),
  72. *usr2_uri = LSUP_iriref_new ("#usr2", NULL);
  73. LSUP_Graph
  74. *gr1 = LSUP_graph_new(NULL, usr1_uri, NULL),
  75. *gr2 = LSUP_graph_new(NULL, usr2_uri, NULL);
  76. LSUP_term_free (usr1_uri);
  77. LSUP_term_free (usr2_uri);
  78. ttl_codec.
  79. LSUP_Graph *data[] = {gr1, gr2, NULL};
  80. LSR_Desc *rsrc;
  81. EXPECT_PASS (LSR_desc_new_multi (data, &rsrc));
  82. // Free input handles before using the resource to ensure that these
  83. // pointers are not being referenced by the resource.
  84. LSUP_graph_free (gr1);
  85. LSUP_graph_free (gr2);
  86. /*
  87. for (int i = 0; i < 6; i++) {
  88. LSUP_term_free (terms1[i]);
  89. LSUP_term_free (terms2[i]);
  90. }
  91. */
  92. // TODO more action
  93. // Store for next test before freeing.
  94. EXPECT_PASS (LSR_desc_store (rsrc));
  95. LSR_desc_free (rsrc);
  96. return 0;
  97. }
  98. static int
  99. test_desc_get ()
  100. {
  101. return 0;
  102. }
  103. int desc_tests()
  104. {
  105. RUN (test_desc_create);
  106. RUN (test_desc_get);
  107. return 0;
  108. }