-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #14 from samoht/rw
New RO and RW signatures
- Loading branch information
Showing
7 changed files
with
310 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
(test | ||
(name test) | ||
(package mirage-kv) | ||
(libraries mirage-kv alcotest)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
open Mirage_kv | ||
|
||
let key = Alcotest.testable Key.pp Key.equal | ||
|
||
let path_v () = | ||
let check s e = Alcotest.(check string) s e Key.(to_string @@ v s) in | ||
check "/foo/bar" "/foo/bar"; | ||
check "/foo" "/foo"; | ||
check "/" "/"; | ||
check "foo/bar" "/foo/bar"; | ||
check "" "/" | ||
|
||
let path_add () = | ||
let check p b exp = | ||
let f = p ^ "/" ^ b in | ||
let vp = Key.v p in | ||
Alcotest.(check string) f exp Key.(to_string @@ vp / b); | ||
Alcotest.(check key) f vp Key.(parent @@ vp / b); | ||
Alcotest.(check string) f b Key.(basename @@ vp / b) | ||
in | ||
let check_exn p b = | ||
try | ||
let _ = Key.(v p / b) in | ||
Alcotest.failf "%s is not a valid segment, should fail" b | ||
with Failure _ -> () | ||
in | ||
check "" "bar" "/bar"; | ||
check "/" "foo" "/foo"; | ||
check "/foo" "bar" "/foo/bar"; | ||
check "/foo/bar" "toto" "/foo/bar/toto"; | ||
check_exn "" "foo/bar" | ||
|
||
let path_append () = | ||
let check x y = | ||
let f = x ^ "/" ^ y in | ||
let vf = Key.v f in | ||
Alcotest.(check key) f vf Key.(v x // v y); | ||
Alcotest.(check string) x Key.(basename vf) Key.(basename @@ v y) | ||
in | ||
check "" "/foo/bar"; | ||
check "/foo" "bar"; | ||
check "/foo/bar" "/toto/foox/ko" | ||
|
||
let () = Alcotest.run "mirage-kv" [ | ||
"path", [ | ||
"Path.v" , `Quick, path_v; | ||
"Path.add_seg", `Quick, path_add; | ||
"Path.append" , `Quick, path_append; | ||
] | ||
] |