An embedded, single-file key-value store for OCaml, inspired by BoltDB and LMDB.
at main 895 B view raw
1(** Tests for Error module *) 2 3let test_to_string () = 4 let open Lithos.Error in 5 Alcotest.(check string) 6 "IO_error message" 7 "I/O error: file not found" 8 (to_string (IO_error "file not found")); 9 Alcotest.(check string) 10 "Invalid_database message" 11 "Invalid database: bad header" 12 (to_string (Invalid_database "bad header")); 13 Alcotest.(check string) "Database_locked message" "Database is locked" (to_string Database_locked); 14 Alcotest.(check string) "Not_found message" "Not found" (to_string Not_found) 15;; 16 17let test_of_unix_error () = 18 let open Lithos.Error in 19 let err = of_unix_error Unix.ENOENT "/tmp/test.db" in 20 let msg = to_string err in 21 Alcotest.(check bool) 22 "Unix error contains path" 23 true 24 (String.length msg > 0 && String.contains msg '/') 25;; 26 27let suite = [ "to_string", `Quick, test_to_string; "of_unix_error", `Quick, test_of_unix_error ]