(* The element types of jsonb.html, section 3: codes 0 to 12, 13 to 15 reserved, and the names the spec gives them. *) module S = Sql.Jsonb.Sort let test_codes () = for c = 0 to 12 do match S.of_code c with | Some s -> Alcotest.(check int) (S.to_string s) c (S.to_code s) | None -> Alcotest.failf "code %d has no type" c done; List.iter (fun c -> Alcotest.(check bool) (string_of_int c) true (S.of_code c = None)) [ 13; 14; 15; -1; 16 ] let test_names () = Alcotest.(check (list string)) "names" [ "null"; "true"; "false"; "int"; "int5"; "float"; "float5"; "text"; "textj"; "text5"; "textraw"; "array"; "object"; ] (List.init 13 (fun c -> S.to_string (Option.get (S.of_code c)))) let suite = ( "jsonb_sort", [ Alcotest.test_case "codes" `Quick test_codes; Alcotest.test_case "names" `Quick test_names; ] )