aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorarie <arie@alleycat.cc>2021-06-07 11:19:22 +0200
committerarie <arie@alleycat.cc>2021-06-28 21:02:44 +0200
commit8bb06986550c075d9120e0a3619b3e7af01b2871 (patch)
tree758b668319793d367353adbe72fada50b49ffabc /test
parent157927df5907a085c238169b85b0c489384e6bfd (diff)
Rdf_turtle:
added some tests, changed some types.
Diffstat (limited to 'test')
-rw-r--r--test/alcotest/rdf_alcotest.ml4
-rw-r--r--test/alcotest/rdf_alcotest.mli2
-rw-r--r--test/turtle/main.ml92
3 files changed, 94 insertions, 4 deletions
diff --git a/test/alcotest/rdf_alcotest.ml b/test/alcotest/rdf_alcotest.ml
index 8d8ecc1..87d57fe 100644
--- a/test/alcotest/rdf_alcotest.ml
+++ b/test/alcotest/rdf_alcotest.ml
@@ -55,8 +55,8 @@ let ast_collection =
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_bnodeps =
+ Alcotest.testable Rdf_turtle.AST.bnodeps_pp Rdf_turtle.AST.bnodeps_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 2514165..1cf4402 100644
--- a/test/alcotest/rdf_alcotest.mli
+++ b/test/alcotest/rdf_alcotest.mli
@@ -38,6 +38,6 @@ 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_bnodeps : Rdf_turtle.AST.bnodeps Alcotest.testable
val ast_predobjs : Rdf_turtle.AST.predobjs Alcotest.testable
diff --git a/test/turtle/main.ml b/test/turtle/main.ml
index e5c3a59..c2c3b86 100644
--- a/test/turtle/main.ml
+++ b/test/turtle/main.ml
@@ -105,6 +105,23 @@ let literal_test_case =
(Result.ok @@ v))
cases)
+let predicate_test_case =
+ let cases = [
+ "<http://one.example/subject1>",
+ Turtle.Predicate.of_iri @@ Turtle.Iri.of_iriref @@ Turtle.Iriref.of_string "http://one.example/subject1" ;
+ "p:subject3",
+ Turtle.Predicate.of_iri @@ Turtle.Iri.of_prefixed_name @@ Turtle.Prefixed_name.of_strings "p" "subject3" ;
+ ] in
+ test_case "predicate" `Quick
+ (fun () ->
+ List.iter
+ (fun (enc, v) ->
+ check (result Rdf_alcotest.ast_predicate string)
+ "can parse"
+ (parse Parser.predicate enc)
+ (Result.ok @@ v))
+ cases)
+
let object_test_case =
let cases = [
(* Literal *)
@@ -134,8 +151,24 @@ let object_test_case =
(Turtle.Iri.of_prefixed_name @@ Turtle.Prefixed_name.of_strings "xsd" "string")) ;
Turtle.Obj_literal (
Turtle.Literal.make
+ ("banana")
+ (Turtle.Iri.of_prefixed_name @@ Turtle.Prefixed_name.of_strings "xsd" "string")) ;
+ ]
+ )
+ ) ;
+ (* BNodePlist *)
+ "[ foaf:name \"Bob\" ]",
+ 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
+ ("banana")
+ (Turtle.Iri.of_prefixed_name @@ Turtle.Prefixed_name.of_strings "xsd" "string")) ;
]
)
) ;
@@ -150,6 +183,60 @@ let object_test_case =
(Result.ok @@ v))
cases)
+let bnodeps_test_case =
+ let cases = [
+ ] in
+ test_case "bnodeps" `Quick
+ (fun () ->
+ List.iter
+ (fun (enc, v) ->
+ check (result Rdf_alcotest.ast_bnodeps string)
+ "can parse"
+ (parse Parser.bnodeps enc)
+ (Result.ok @@ v))
+ cases)
+
+let predobjs_test_case =
+ let cases = [
+ " foaf:name \"Bob\" ",
+ [ Turtle.Predicate.of_iri @@ Turtle.Iri.of_prefixed_name @@ Turtle.Prefixed_name.of_strings "foaf" "name",
+ [ Turtle.Obj_literal ( Turtle.Literal.make
+ ("Bob")
+ (Turtle.Iri.of_prefixed_name @@ Turtle.Prefixed_name.of_strings "xsd" "string"))
+ ]
+ ]
+ ;
+ ] in
+ test_case "predobjs" `Quick
+ (fun () ->
+ List.iter
+ (fun (enc, v) ->
+ check (result Rdf_alcotest.ast_predobjs string)
+ "can parse"
+ (parse Parser.predobjs enc)
+ (Result.ok @@ v))
+ cases)
+
+let test_test_case =
+ let cases = [
+ " foaf:name \"Bob\" ",
+ [ Turtle.Predicate.of_iri @@ Turtle.Iri.of_prefixed_name @@ Turtle.Prefixed_name.of_strings "foaf" "name",
+ [ Turtle.Obj_literal ( Turtle.Literal.make
+ ("Bob")
+ (Turtle.Iri.of_prefixed_name @@ Turtle.Prefixed_name.of_strings "xsd" "string"))
+ ]
+ ]
+ ;
+ ] in
+ test_case "predobjs" `Quick
+ (fun () ->
+ List.iter
+ (fun (enc, v) ->
+ check (result Rdf_alcotest.ast_predobjs string)
+ "can parse"
+ (parse Parser.test_parser enc)
+ (Result.ok @@ v))
+ cases)
let () =
Alcotest.run "Turtle" [
"Basic parsers", [
@@ -159,6 +246,9 @@ let () =
blank_node_test_case;
iri_test_case;
literal_test_case;
- object_test_case;
+ predicate_test_case;
+(* object_test_case; *)
+ bnodeps_test_case;
+ predobjs_test_case;
]
]