aboutsummaryrefslogtreecommitdiff
path: root/test/json/main.ml
blob: 2b2073ddb0dced03b6c3a4f69277b86334555d25 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
module Triple = Rdf.Triple

let encode_decode_subject =
  QCheck.Test.make ~name:"decode encode subject"
    Rdf_gen.subject
    (fun subject -> Triple.Subject.equal
      subject
      (subject |> Rdf_json.encode_subject |> Rdf_json.decode_subject))

let encode_decode_predicate =
  QCheck.Test.make ~name:"decode encode predicate"
    Rdf_gen.predicate
    (fun predicate -> Triple.Predicate.equal
      predicate
      (predicate |> Rdf_json.encode_predicate |> Rdf_json.decode_predicate))

let encode_decode_object =
  QCheck.Test.make ~name:"decode encode object"
    Rdf_gen.object'
    (fun object' ->
       Triple.Object.equal
      object'
      (object' |> Rdf_json.encode_object |> Rdf_json.decode_object))

let encode_decode_triple_test =
  QCheck.Test.make ~name:"decode encode"
    Rdf_gen.triple
    (fun triple ->
       [triple] = (Rdf_json.encode [triple]
                   |> Rdf_json.decode))

let _encode_decode_triple_list_test =
  let triple_list_arbitrary =
    Rdf_gen.triple
    |> QCheck.list
  in
  QCheck_alcotest.to_alcotest @@
  QCheck.Test.make ~name:"decode encode"
    triple_list_arbitrary
    (fun lst ->
       lst = (Rdf_json.encode lst
       |> Rdf_json.decode))



let () =
  Alcotest.run "Json" [
    "Encoder", List.map QCheck_alcotest.to_alcotest [
(*       encode_decode_triple_list_test; *)
(*       encode_decode_triple_test; *)
      encode_decode_subject;
      encode_decode_predicate;
      encode_decode_object;
    ]
  ]