Skip to content

Commit

Permalink
Merge branch 'master' of github.com:mirage/ocaml-cstruct
Browse files Browse the repository at this point in the history
  • Loading branch information
avsm committed Mar 2, 2019
2 parents 3f39a79 + 0dd1dfa commit 1e57c2a
Show file tree
Hide file tree
Showing 9 changed files with 1,938 additions and 42 deletions.
8 changes: 3 additions & 5 deletions lib_test/dune
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
(executables
(executable
(libraries cstruct alcotest)
(names tests bounds))
(name tests))

(alias
(name runtest)
(package cstruct)
(deps
(:< tests.exe))
(action
(run %{<} -e)))
(run ./tests.exe -e)))
10 changes: 10 additions & 0 deletions ppx_test/basic.expected
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
deadbeef deadbeef
foo = {
a = 0x7
b = 0x2c
c = 0xbeef
d = <buffer uint8_t[8] d>
61 62 63 64 65 66 67 68

}
"\007\000,\000\000\190\239abcdefgh"
6 changes: 4 additions & 2 deletions ppx_test/basic.ml
Original file line number Diff line number Diff line change
Expand Up @@ -107,12 +107,12 @@ let tests () =
let bibe = Cstruct.of_bigarray (Bigarray.(Array1.create char c_layout BE.sizeof_bibar)) in
for i = 0 to 65535 do
BE.set_bibar_a bibe i;
assert(BE.get_bibar_a bibe = i)
assert(BE.get_bibar_a bibe = i mod 256)
done;
let bile = Cstruct.of_bigarray (Bigarray.(Array1.create char c_layout LE.sizeof_bibar)) in
for i = 0 to 65535 do
LE.set_bibar_a bile i;
assert(LE.get_bibar_a bile = i)
assert(LE.get_bibar_a bile = i mod 256)
done;
let be = Cstruct.of_bigarray (Bigarray.(Array1.create char c_layout sizeof_foo)) in
let rec fn = function
Expand Down Expand Up @@ -152,3 +152,5 @@ let tests () =
assert(get_foo_a be = 7);
hexdump_foo be;
print_endline (Sexplib.Sexp.to_string_hum (Cstruct.sexp_of_t be))

let () = tests ()
33 changes: 5 additions & 28 deletions ppx_test/dune
Original file line number Diff line number Diff line change
@@ -1,29 +1,6 @@
(executables
(tests
(names pcap basic enum)
(deps http.cap)
(libraries cstruct-unix)
(preprocess
(pps ppx_cstruct))
(names pcap basic enum))

(alias
(name runtest)
(package ppx_cstruct)
(deps
(:< pcap.exe))
(action
(run %{<})))

(alias
(name runtest)
(package ppx_cstruct)
(deps
(:< basic.exe))
(action
(run %{<})))

(alias
(name runtest)
(package ppx_cstruct)
(deps
(:< enum.exe))
(action
(run %{<})))
(preprocess (pps ppx_cstruct))
(package ppx_cstruct))
2 changes: 2 additions & 0 deletions ppx_test/enum.ml
Original file line number Diff line number Diff line change
Expand Up @@ -80,3 +80,5 @@ let tests () =
assert(int_to_foo32 0xffffffffl = Some (THREE32));
assert(string_to_foo16 "ONE16" = Some ONE16);
assert(foo8_to_string ONE8 = "ONE8")

let () = tests ()
Loading

0 comments on commit 1e57c2a

Please sign in to comment.