File: test_util.ml

package info (click to toggle)
yojson 2.2.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,216 kB
  • sloc: ml: 3,890; makefile: 28
file content (22 lines) | stat: -rw-r--r-- 629 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
let path_empty () =
  Alcotest.(check (option Testable.yojson))
    __LOC__ (Some Fixtures.json_value)
    (Yojson.Safe.Util.path [] Fixtures.json_value)

let path_missing () =
  Alcotest.(check (option Testable.yojson))
    __LOC__ None
    (Yojson.Safe.Util.path [ "does not exist" ] Fixtures.json_value)

let path_traverse () =
  Alcotest.(check (option Testable.yojson))
    __LOC__
    (Some (`Int 42))
    (Yojson.Safe.Util.path [ "assoc"; "value" ] Fixtures.json_value)

let tests =
  [
    ("empty path", `Quick, path_empty);
    ("non-existing path", `Quick, path_missing);
    ("traversal", `Quick, path_traverse);
  ]