diff options
author | pukkamustard <pukkamustard@posteo.net> | 2021-06-28 13:17:07 +0200 |
---|---|---|
committer | pukkamustard <pukkamustard@posteo.net> | 2021-06-28 13:17:07 +0200 |
commit | a82f31e6c66ed56d53aad07c4d1d587d1280bf39 (patch) | |
tree | 7d7ee9dddc33c81f1663267d08d04c56d9830618 /test | |
parent | e1d5560be2af20245caa876c856c1c7cf56fbd13 (diff) |
Rdf.Graph: add `equal` function
Diffstat (limited to 'test')
-rw-r--r-- | test/core/main.ml | 68 |
1 files changed, 66 insertions, 2 deletions
diff --git a/test/core/main.ml b/test/core/main.ml index 0b98968..5bf6987 100644 --- a/test/core/main.ml +++ b/test/core/main.ml @@ -5,5 +5,69 @@ * SPDX-License-Identifier: AGPL-3.0-or-later *) -(* TODO *) -print_endline "crickets..." + +let ex = Rdf.Namespace.make_namespace "http://example.com/" +let ex2 = Rdf.Namespace.make_namespace "http://example2.com/" + +module GraphTest = struct + + let equal_unit_test = + let open Alcotest in + test_case "equality unit tests" + `Quick + (fun () -> + check bool + "empty graphs are equal" + true + Rdf.Graph.(equal empty empty); + + + check bool + "graph with one element added is not equal to empty graph" + false + Rdf.Graph.(equal empty @@ + add empty Rdf.Triple.( + make + (Subject.of_iri @@ ex "foo") + (Predicate.of_iri @@ ex "prop") + (Object.of_iri @@ ex "bar"))); + + check bool + "graph with one element is equal" + true + Rdf.Graph.(equal + (add empty + Rdf.Triple.(make + (Subject.of_iri @@ ex "foo") + (Predicate.of_iri @@ ex "prop") + (Object.of_iri @@ ex "bar"))) + (add empty + Rdf.Triple.(make + (Subject.of_iri @@ ex "foo") + (Predicate.of_iri @@ ex "prop") + (Object.of_iri @@ ex "bar")))); + + check bool + "graph with two different elements is not equal" + false + Rdf.Graph.(equal + (add empty + Rdf.Triple.(make + (Subject.of_iri @@ ex "foo") + (Predicate.of_iri @@ ex "prop") + (Object.of_iri @@ ex "bar"))) + (add empty + Rdf.Triple.(make + (Subject.of_iri @@ ex2 "foo") + (Predicate.of_iri @@ ex "prop") + (Object.of_iri @@ ex "bar")))); + + ) + + let testcases = [equal_unit_test] +end + +let () = + Alcotest.run "rdf" [ + "Rdf.Graph", GraphTest.testcases + ] |