-
Notifications
You must be signed in to change notification settings - Fork 83
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
47 additions
and
50 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,24 @@ | ||
let (>>=) = Lwt.(>>=) | ||
open Lwt.Infix | ||
|
||
let fail fmt = Fmt.kstrf Alcotest.fail fmt | ||
let failf fmt = Fmt.kstrf Alcotest.fail fmt | ||
|
||
let or_error name fn t = | ||
fn t >>= function | ||
| Error _ -> fail "or_error starting %s" name | ||
| Error _ -> failf "or_error starting %s" name | ||
| Ok t -> Lwt.return t | ||
|
||
let expect_error error name fn t = | ||
fn t >>= function | ||
| Error error2 when error2 = error -> Lwt.return t | ||
| _ -> fail "expected error on %s" name | ||
| _ -> failf "expected error on %s" name | ||
|
||
let cstruct = | ||
let module M = struct | ||
type t = Cstruct.t | ||
let pp = Cstruct.hexdump_pp | ||
let equal = Cstruct.equal | ||
end in | ||
(module M : Alcotest.TESTABLE with type t = M.t) | ||
|
||
let ipv4_packet = (module Ipv4_packet : Alcotest.TESTABLE with type t = Ipv4_packet.t) | ||
let udp_packet = (module Udp_packet : Alcotest.TESTABLE with type t = Udp_packet.t) | ||
let tcp_packet = (module Tcp.Tcp_packet : Alcotest.TESTABLE with type t = Tcp.Tcp_packet.t) | ||
let ipv4_packet = Alcotest.testable Ipv4_packet.pp Ipv4_packet.equal | ||
let udp_packet = Alcotest.testable Udp_packet.pp Udp_packet.equal | ||
let tcp_packet = Alcotest.testable Tcp.Tcp_packet.pp Tcp.Tcp_packet.equal | ||
let cstruct = Alcotest.testable Cstruct.hexdump_pp Cstruct.equal | ||
|
||
let sequence = | ||
let module M = struct | ||
type t = Tcp.Sequence.t | ||
let pp = Tcp.Sequence.pp | ||
let equal x y = (=) 0 @@ Tcp.Sequence.compare x y | ||
end in | ||
(module M : Alcotest.TESTABLE with type t = M.t) | ||
let eq x y = Tcp.Sequence.compare x y = 0 in | ||
Alcotest.testable Tcp.Sequence.pp eq | ||
|
||
let options = Alcotest.testable Tcp.Options.pp Tcp.Options.equal |
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
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