#hex #format #panics #display #displaying #protocols

assert_hex

display assert panics in hexadecimal {:#x?} format

8 unstable releases (3 breaking)

0.4.1 Sep 17, 2023
0.4.0 Sep 11, 2023
0.3.0 Aug 30, 2023
0.2.2 Jan 30, 2021
0.1.0 Mar 9, 2020

#93 in Testing

Download history 282/week @ 2023-12-24 118/week @ 2023-12-31 303/week @ 2024-01-07 373/week @ 2024-01-14 351/week @ 2024-01-21 231/week @ 2024-01-28 251/week @ 2024-02-04 239/week @ 2024-02-11 317/week @ 2024-02-18 276/week @ 2024-02-25 470/week @ 2024-03-03 568/week @ 2024-03-10 354/week @ 2024-03-17 584/week @ 2024-03-24 506/week @ 2024-03-31 315/week @ 2024-04-07

1,798 downloads per month
Used in 11 crates

MIT license

7KB
118 lines

assert_hex

Latest Version Rust Documentation Crates.io

display expression using {:#x?} format when false assertion causes panic!().

Why

Writing and testing protocol level libraries requires many tests to be written with respect to byte level protocol sections in hex. This library simplifies the process of viewing the differences between these types when tests fail by displaying by using the {:#x?} representation.

Usage

Compiler support: requires rustc 1.39+

$ cargo add assert_hex

Replace assert_eq or assert_ne with assert_eq_hex or assert_ne_hex respectively.

Changelog

See CHANGELOG.md


lib.rs:

assert_hex

display expression using {:#x?} format when false assertion causes panic!().

why

Writing and testing protocol level libraries requires many tests to be written with respect to byte level protocol sections in hex. This library simplifies the process of viewing the differences between these types when tests fail by displaying by using the {:#x?} representation.

usage

Replace assert_eq or assert_ne with assert_eq_hex or assert_ne_hex respectively.

No runtime deps