aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorarie <arie@alleycat.cc>2021-05-04 15:22:20 +0200
committerarie <arie@alleycat.cc>2021-05-04 15:22:20 +0200
commit128d4f88ce14c3ce212546d21387b77c89c7851b (patch)
tree7399f6f976d651016e5ed3133c48b2603054463c /test
parent6831abaf2f57b61bdc098daf76be38676842cb55 (diff)
Rdf_gen:
add subject, object, predicate, triple and namespace generators. Rdf_json test: add encode decode test, still fails.
Diffstat (limited to 'test')
-rw-r--r--test/json/dune9
-rw-r--r--test/json/main.ml32
2 files changed, 41 insertions, 0 deletions
diff --git a/test/json/dune b/test/json/dune
new file mode 100644
index 0000000..da3cc99
--- /dev/null
+++ b/test/json/dune
@@ -0,0 +1,9 @@
+(executables
+ (names main)
+ (libraries rdf_json rdf_gen
+ yojson alcotest qcheck-alcotest))
+
+(rule
+ (alias runtest)
+ (action (run ./main.exe)))
+
diff --git a/test/json/main.ml b/test/json/main.ml
new file mode 100644
index 0000000..8e4a41c
--- /dev/null
+++ b/test/json/main.ml
@@ -0,0 +1,32 @@
+let _triple = Rdf_gen.triple
+
+let encode_decode_triple_test =
+ QCheck_alcotest.to_alcotest @@
+ QCheck.Test.make ~name:"decode encode"
+ Rdf_gen.triple
+ (fun triple ->
+ [triple] = (Rdf_json.encode [triple]
+ |> Rdf_json.decode))
+
+let encode_decode_triple_list_test =
+ let triple_list_arbitrary =
+ Rdf_gen.triple
+ |> QCheck.list
+ in
+ QCheck_alcotest.to_alcotest @@
+ QCheck.Test.make ~name:"decode encode"
+ triple_list_arbitrary
+ (fun lst ->
+ lst = (Rdf_json.encode lst
+ |> Rdf_json.decode))
+
+
+
+let () =
+ Alcotest.run "Json" [
+ "Encoder", [
+(* encode_decode_triple_list_test; *)
+ encode_decode_triple_test;
+ ]
+ ]
+