Skip to content

Commit 1e57c2a

Browse files
committed
Merge branch 'master' of github.com:mirage/ocaml-cstruct
2 parents 3f39a79 + 0dd1dfa commit 1e57c2a

File tree

9 files changed

+1938
-42
lines changed

9 files changed

+1938
-42
lines changed

lib_test/dune

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
1-
(executables
1+
(executable
22
(libraries cstruct alcotest)
3-
(names tests bounds))
3+
(name tests))
44

55
(alias
66
(name runtest)
77
(package cstruct)
8-
(deps
9-
(:< tests.exe))
108
(action
11-
(run %{<} -e)))
9+
(run ./tests.exe -e)))

ppx_test/basic.expected

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
deadbeef deadbeef
2+
foo = {
3+
a = 0x7
4+
b = 0x2c
5+
c = 0xbeef
6+
d = <buffer uint8_t[8] d>
7+
61 62 63 64 65 66 67 68
8+
9+
}
10+
"\007\000,\000\000\190\239abcdefgh"

ppx_test/basic.ml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,12 +107,12 @@ let tests () =
107107
let bibe = Cstruct.of_bigarray (Bigarray.(Array1.create char c_layout BE.sizeof_bibar)) in
108108
for i = 0 to 65535 do
109109
BE.set_bibar_a bibe i;
110-
assert(BE.get_bibar_a bibe = i)
110+
assert(BE.get_bibar_a bibe = i mod 256)
111111
done;
112112
let bile = Cstruct.of_bigarray (Bigarray.(Array1.create char c_layout LE.sizeof_bibar)) in
113113
for i = 0 to 65535 do
114114
LE.set_bibar_a bile i;
115-
assert(LE.get_bibar_a bile = i)
115+
assert(LE.get_bibar_a bile = i mod 256)
116116
done;
117117
let be = Cstruct.of_bigarray (Bigarray.(Array1.create char c_layout sizeof_foo)) in
118118
let rec fn = function
@@ -152,3 +152,5 @@ let tests () =
152152
assert(get_foo_a be = 7);
153153
hexdump_foo be;
154154
print_endline (Sexplib.Sexp.to_string_hum (Cstruct.sexp_of_t be))
155+
156+
let () = tests ()

ppx_test/dune

Lines changed: 5 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,6 @@
1-
(executables
1+
(tests
2+
(names pcap basic enum)
3+
(deps http.cap)
24
(libraries cstruct-unix)
3-
(preprocess
4-
(pps ppx_cstruct))
5-
(names pcap basic enum))
6-
7-
(alias
8-
(name runtest)
9-
(package ppx_cstruct)
10-
(deps
11-
(:< pcap.exe))
12-
(action
13-
(run %{<})))
14-
15-
(alias
16-
(name runtest)
17-
(package ppx_cstruct)
18-
(deps
19-
(:< basic.exe))
20-
(action
21-
(run %{<})))
22-
23-
(alias
24-
(name runtest)
25-
(package ppx_cstruct)
26-
(deps
27-
(:< enum.exe))
28-
(action
29-
(run %{<})))
5+
(preprocess (pps ppx_cstruct))
6+
(package ppx_cstruct))

ppx_test/enum.ml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,3 +80,5 @@ let tests () =
8080
assert(int_to_foo32 0xffffffffl = Some (THREE32));
8181
assert(string_to_foo16 "ONE16" = Some ONE16);
8282
assert(foo8_to_string ONE8 = "ONE8")
83+
84+
let () = tests ()

0 commit comments

Comments
 (0)