aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorarie <arie@alleycat.cc>2021-06-07 17:01:06 +0200
committerarie <arie@alleycat.cc>2021-06-28 21:02:45 +0200
commit933fde01c878fbe20952c05ad700fecd0c0286ef (patch)
treeaea60c41b1f57305ad3a68c20e6fb205547f286e /test
parent618d4dc294d0613de8747a2b14aec89429958b8a (diff)
Rdf turtle
add test for directive, improved types, added some pp and equal functions.
Diffstat (limited to 'test')
-rw-r--r--test/alcotest/rdf_alcotest.ml12
-rw-r--r--test/alcotest/rdf_alcotest.mli9
-rw-r--r--test/turtle/main.ml16
3 files changed, 37 insertions, 0 deletions
diff --git a/test/alcotest/rdf_alcotest.ml b/test/alcotest/rdf_alcotest.ml
index 87d57fe..88e9831 100644
--- a/test/alcotest/rdf_alcotest.ml
+++ b/test/alcotest/rdf_alcotest.ml
@@ -60,3 +60,15 @@ let ast_bnodeps =
let ast_predobjs =
Alcotest.testable Rdf_turtle.AST.predobjs_pp Rdf_turtle.AST.predobjs_equal
+
+let ast_triples =
+ Alcotest.testable Rdf_turtle.AST.Triples.pp Rdf_turtle.AST.Triples.equal
+
+let ast_directive =
+ Alcotest.testable Rdf_turtle.AST.Directive.pp Rdf_turtle.AST.Directive.equal
+
+let ast_statement =
+ Alcotest.testable Rdf_turtle.AST.Statement.pp Rdf_turtle.AST.Statement.equal
+
+let ast_turtle =
+ Alcotest.testable Rdf_turtle.AST.Turtle.pp Rdf_turtle.AST.Turtle.equal
diff --git a/test/alcotest/rdf_alcotest.mli b/test/alcotest/rdf_alcotest.mli
index 1cf4402..56a0e57 100644
--- a/test/alcotest/rdf_alcotest.mli
+++ b/test/alcotest/rdf_alcotest.mli
@@ -41,3 +41,12 @@ val ast_subject : Rdf_turtle.AST.subject Alcotest.testable
val ast_bnodeps : Rdf_turtle.AST.bnodeps Alcotest.testable
val ast_predobjs : Rdf_turtle.AST.predobjs Alcotest.testable
+
+val ast_triples : Rdf_turtle.AST.Triples.t Alcotest.testable
+
+val ast_directive : Rdf_turtle.AST.Directive.t Alcotest.testable
+
+val ast_statement : Rdf_turtle.AST.Statement.t Alcotest.testable
+
+val ast_turtle : Rdf_turtle.AST.Turtle.t Alcotest.testable
+
diff --git a/test/turtle/main.ml b/test/turtle/main.ml
index 6ada3e4..d70ca4e 100644
--- a/test/turtle/main.ml
+++ b/test/turtle/main.ml
@@ -237,6 +237,21 @@ let predobjs_test_case =
(Result.ok @@ v))
cases)
+let directive_test_case =
+ let cases = [
+ "@base <http://one.example/> .",
+ Turtle.Directive.of_iriref (Turtle.Iriref.of_string "http://one.example/")
+ ] in
+ test_case "directive" `Quick
+ (fun () ->
+ List.iter
+ (fun (enc, v) ->
+ check (result Rdf_alcotest.ast_directive string)
+ "can parse"
+ (parse Parser.directive enc)
+ (Result.ok @@ v))
+ cases)
+
let () =
Alcotest.run "Turtle" [
"Basic parsers", [
@@ -250,5 +265,6 @@ let () =
object_test_case;
bnodeps_test_case;
predobjs_test_case;
+ directive_test_case;
]
]