···235235}
236236237237#[cfg(test)]
238238+/// We want to test all of these functions against the actual values produced by
239239+/// Erlang when turning some data into a binary.
240240+///
241241+/// All the bytes you see in the assertions here were produced using the
242242+/// following bit of Erlang:
243243+///
244244+/// ```erl
245245+/// Binary = term_to_binary(SomeErlangData),
246246+/// io:format("~w~n", [Binary]).
247247+/// ```
248248+///
249249+/// This will turn any data structure into its binary representation and print
250250+/// its bytes we can then copy paste in these tests.
251251+///
252252+/// For example: if I were to test that a list of two atoms is correctly turned
253253+/// into its binary representation I would write the following:
254254+///
255255+/// ```erl
256256+/// Binary = term_to_binary([nil, ok]),
257257+/// io:format("~w~n", [Binary]).
258258+/// ```
259259+///
260260+/// And write a test like this:
261261+///
262262+/// ```ignore
263263+/// let mut etf = Builder::new();
264264+/// let list = etf.start_list();
265265+/// etf.atom("nil");
266266+/// etf.atom("ok");
267267+/// etf.end_list(list, 2);
268268+///
269269+/// assert_eq!(
270270+/// etf.into_vec(),
271271+/// [... the bytes I got from the Erlang code ...]
272272+/// )
273273+/// ```
274274+///
238275mod tests {
239276 use std::{ops::Neg, str::FromStr};
240277