aboutsummaryrefslogtreecommitdiff
path: root/test/turtle/main.ml
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/turtle/main.ml
parent69ae7300da09315ffec8b3699b032dbfc3863e4f (diff)
Rdf turtle tests
add some more tests. Improve parsers.
Diffstat (limited to 'test/turtle/main.ml')
-rw-r--r--test/turtle/main.ml46
1 files changed, 46 insertions, 0 deletions
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;
]
]