aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorarie <arie@alleycat.cc>2021-05-31 15:45:12 +0200
committerarie <arie@alleycat.cc>2021-06-28 21:02:44 +0200
commit157927df5907a085c238169b85b0c489384e6bfd (patch)
treed235ce4fb445b67f6c2ce37c6655a774aeb9369f /test
parent69ae7300da09315ffec8b3699b032dbfc3863e4f (diff)
Rdf turtle tests
add some more tests. Improve parsers.
Diffstat (limited to 'test')
-rw-r--r--test/alcotest/rdf_alcotest.ml15
-rw-r--r--test/alcotest/rdf_alcotest.mli10
-rw-r--r--test/turtle/main.ml46
3 files changed, 71 insertions, 0 deletions
diff --git a/test/alcotest/rdf_alcotest.ml b/test/alcotest/rdf_alcotest.ml
index 7144f27..8d8ecc1 100644
--- a/test/alcotest/rdf_alcotest.ml
+++ b/test/alcotest/rdf_alcotest.ml
@@ -45,3 +45,18 @@ let ast_literal =
let ast_predicate =
Alcotest.testable Rdf_turtle.AST.Predicate.pp Rdf_turtle.AST.Predicate.equal
+
+let ast_object =
+ Alcotest.testable Rdf_turtle.AST.object_pp Rdf_turtle.AST.object_equal
+
+let ast_collection =
+ Alcotest.testable Rdf_turtle.AST.collection_pp Rdf_turtle.AST.collection_equal
+
+let ast_subject =
+ Alcotest.testable Rdf_turtle.AST.subject_pp Rdf_turtle.AST.subject_equal
+
+let ast_bnodep =
+ Alcotest.testable Rdf_turtle.AST.bnodep_pp Rdf_turtle.AST.bnodep_equal
+
+let ast_predobjs =
+ Alcotest.testable Rdf_turtle.AST.predobjs_pp Rdf_turtle.AST.predobjs_equal
diff --git a/test/alcotest/rdf_alcotest.mli b/test/alcotest/rdf_alcotest.mli
index 144c5ec..2514165 100644
--- a/test/alcotest/rdf_alcotest.mli
+++ b/test/alcotest/rdf_alcotest.mli
@@ -31,3 +31,13 @@ val ast_iri: Rdf_turtle.AST.Iri.t Alcotest.testable
val ast_literal : Rdf_turtle.AST.Literal.t Alcotest.testable
val ast_predicate : Rdf_turtle.AST.Predicate.t Alcotest.testable
+
+val ast_object : Rdf_turtle.AST.object' Alcotest.testable
+
+val ast_collection : Rdf_turtle.AST.collection Alcotest.testable
+
+val ast_subject : Rdf_turtle.AST.subject Alcotest.testable
+
+val ast_bnodep : Rdf_turtle.AST.bnodep Alcotest.testable
+
+val ast_predobjs : Rdf_turtle.AST.predobjs Alcotest.testable
diff --git a/test/turtle/main.ml b/test/turtle/main.ml
index e6ee3c3..e5c3a59 100644
--- a/test/turtle/main.ml
+++ b/test/turtle/main.ml
@@ -105,6 +105,51 @@ let literal_test_case =
(Result.ok @@ v))
cases)
+let object_test_case =
+ let cases = [
+ (* Literal *)
+ "\"That Seventies Show\"^^xsd:string",
+ Turtle.Literal.make
+ ("That Seventies Show")
+ (Turtle.Iri.of_prefixed_name @@ Turtle.Prefixed_name.of_strings "xsd" "string")
+ |> (fun lit -> Turtle.Obj_literal lit) ;
+ (* Iri *)
+ "xsd:string",
+ Turtle.Iri.of_prefixed_name @@ Turtle.Prefixed_name.of_strings "xsd" "string"
+ |> (fun iri -> Turtle.Obj_iri iri) ;
+ (* Blank_node *)
+ "_:string",
+ Turtle.Obj_blank_node (Turtle.Blank_node.of_string "string") ;
+ (* Blank_node *)
+ "_:string",
+ Turtle.Obj_blank_node (Turtle.Blank_node.of_string "string") ;
+ (* Collection *)
+ "( \"apple\" \"banana\" )",
+ Turtle.Obj_coll (
+ Turtle.Collection (
+ [
+ Turtle.Obj_literal (
+ Turtle.Literal.make
+ ("apple")
+ (Turtle.Iri.of_prefixed_name @@ Turtle.Prefixed_name.of_strings "xsd" "string")) ;
+ Turtle.Obj_literal (
+ Turtle.Literal.make
+ ("apple")
+ (Turtle.Iri.of_prefixed_name @@ Turtle.Prefixed_name.of_strings "xsd" "string")) ;
+ ]
+ )
+ ) ;
+ ] in
+ test_case "object" `Quick
+ (fun () ->
+ List.iter
+ (fun (enc, v) ->
+ check (result Rdf_alcotest.ast_object string)
+ "can parse"
+ (parse Parser.object' enc)
+ (Result.ok @@ v))
+ cases)
+
let () =
Alcotest.run "Turtle" [
"Basic parsers", [
@@ -114,5 +159,6 @@ let () =
blank_node_test_case;
iri_test_case;
literal_test_case;
+ object_test_case;
]
]