Skip to content

Commit 13bfb4b

Browse files
committed
Add a test
1 parent 0f2be16 commit 13bfb4b

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

ppx_test/basic.expected

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,9 @@ foo = {
88

99
}
1010
"\007\000,\000\000\190\239abcdefgh"
11+
with_ignored_field = {
12+
a = 0x1
13+
_b = 0x2
14+
c = 0x3
15+
16+
}

ppx_test/basic.ml

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,20 @@ type unused = {
7272
} [@@big_endian]
7373
]
7474

75+
let set_with_ignored_field__b = true
76+
77+
let _ : bool = set_with_ignored_field__b
78+
79+
[%%cstruct
80+
type with_ignored_field = {
81+
a : uint8_t;
82+
_b : uint8_t;
83+
c : uint8_t;
84+
} [@@little_endian]
85+
]
86+
87+
let _ : Cstruct.t -> int -> unit = set_with_ignored_field__b
88+
7589
let tests () =
7690
(* Test basic set/get functions *)
7791
let be = Cstruct.of_bigarray (Bigarray.(Array1.create char c_layout sizeof_foo)) in
@@ -151,6 +165,7 @@ let tests () =
151165
assert(get_foo_b be = 44);
152166
assert(get_foo_a be = 7);
153167
hexdump_foo be;
154-
print_endline (Sexplib.Sexp.to_string_hum (Cstruct.sexp_of_t be))
168+
print_endline (Sexplib.Sexp.to_string_hum (Cstruct.sexp_of_t be));
169+
hexdump_with_ignored_field (Cstruct.of_hex "010203")
155170

156171
let () = tests ()

0 commit comments

Comments
 (0)