Skip to content

Commit 943dbdd

Browse files
committed
add rountrip test for IPv6 string parsing
1 parent 96e82bd commit 943dbdd

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

test/Test.ml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
open Packet
22
open QuickCheck
3+
open Arbitrary_Base
34

45
module Gen = QuickCheck_gen
56

@@ -104,6 +105,23 @@ module RoundTrip = struct
104105
(packet_quickCheck (mk_ip tcp)
105106
(prop_roundtrip2 parse marshal))
106107

108+
let addr_roundtrip parse marshal e =
109+
(parse (marshal e)) = e
110+
111+
let addr_quickcheck arbitrary parse marshal =
112+
let show (p1,p2) =
113+
Format.sprintf "%Lu %Lu" p1 p2 in
114+
let test = testable_fun arbitrary show testable_bool in
115+
match quickCheck test (addr_roundtrip parse marshal) with
116+
| Success -> true
117+
| Failure _ -> failwith "No failure expected"
118+
| Exhausted _ -> failwith "No exhaustion expected"
119+
120+
TEST "Roundtrip property for IPv6 Address" =
121+
(addr_quickcheck arbitrary_uint128
122+
ipv6_of_string string_of_ipv6)
123+
124+
107125
end
108126

109127
Pa_ounit_lib.Runtime.summarize ()

0 commit comments

Comments
 (0)