aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorpukkamustard <pukkamustard@posteo.net>2021-05-10 10:50:14 +0200
committerarie <arie@alleycat.cc>2021-05-17 12:41:16 +0200
commitff6b06ec2295e35a9f2e6e029a06fdea927ed883 (patch)
tree181daeeb050aa1882d9ebf3da6d2ebbe9d7f2441 /test
parent2491dd9b97a43d4e8872d20c7bd559d7d73807de (diff)
Rdf_alcotest: Add Alcotest testables for Rdf core types.
This should make it easier to write tests that compare Rdf core types. As they can be used with `Alcotest.check`.
Diffstat (limited to 'test')
-rw-r--r--test/alcotest/dune3
-rw-r--r--test/alcotest/rdf_alcotest.ml11
-rw-r--r--test/alcotest/rdf_alcotest.mli9
-rw-r--r--test/cbor/dune2
-rw-r--r--test/cbor/main.ml14
5 files changed, 33 insertions, 6 deletions
diff --git a/test/alcotest/dune b/test/alcotest/dune
new file mode 100644
index 0000000..ebb0692
--- /dev/null
+++ b/test/alcotest/dune
@@ -0,0 +1,3 @@
+(library
+ (name rdf_alcotest)
+ (libraries rdf alcotest))
diff --git a/test/alcotest/rdf_alcotest.ml b/test/alcotest/rdf_alcotest.ml
new file mode 100644
index 0000000..b50a922
--- /dev/null
+++ b/test/alcotest/rdf_alcotest.ml
@@ -0,0 +1,11 @@
+let iri =
+ Alcotest.testable Rdf.Iri.pp Rdf.Iri.equal
+
+let blank_node =
+ Alcotest.testable Rdf.Blank_node.pp Rdf.Blank_node.equal
+
+let literal =
+ Alcotest.testable Rdf.Literal.pp Rdf.Literal.equal
+
+let term =
+ Alcotest.testable Rdf.Term.pp Rdf.Term.equal
diff --git a/test/alcotest/rdf_alcotest.mli b/test/alcotest/rdf_alcotest.mli
new file mode 100644
index 0000000..1f3fc50
--- /dev/null
+++ b/test/alcotest/rdf_alcotest.mli
@@ -0,0 +1,9 @@
+(** Alcotest testables for Rdf types. *)
+
+val iri : Rdf.Iri.t Alcotest.testable
+
+val blank_node : Rdf.Blank_node.t Alcotest.testable
+
+val literal : Rdf.Literal.t Alcotest.testable
+
+val term : Rdf.Term.t Alcotest.testable
diff --git a/test/cbor/dune b/test/cbor/dune
index 26a2f33..354e77d 100644
--- a/test/cbor/dune
+++ b/test/cbor/dune
@@ -1,7 +1,7 @@
(executables
(names main)
(libraries rdf rdf_cbor
- rdf_gen
+ rdf_gen rdf_alcotest
alcotest qcheck qcheck-alcotest))
(rule
diff --git a/test/cbor/main.ml b/test/cbor/main.ml
index 216719b..c82c4ec 100644
--- a/test/cbor/main.ml
+++ b/test/cbor/main.ml
@@ -14,11 +14,15 @@ let encode_decode_test =
~name:"encode/decode"
Rdf_gen.term
(fun term ->
- Term.equal term
- (term
- |> Rdf_cbor.encode_term
- |> Rdf_cbor.decode_term
- ))
+ Alcotest.check Rdf_alcotest.term
+ "encode/decode"
+ term (term
+ |> Rdf_cbor.encode_term
+ |> Rdf_cbor.decode_term
+ );
+ true
+ )
+
let () =
Alcotest.run "rdf_cbor" [