#regex #matches #assert #string #macro #asserting

assert_matches_regex

Macro for asserting that a string matches a regex

1 unstable release

0.1.0 Nov 18, 2024

#269 in Testing

Download history 162/week @ 2024-11-13 181/week @ 2024-11-20 95/week @ 2024-11-27 163/week @ 2024-12-04 150/week @ 2024-12-11 74/week @ 2024-12-18 23/week @ 2024-12-25 77/week @ 2025-01-01

351 downloads per month

MIT/Apache

8KB
91 lines

assert_matches_regex

Provides a macro, assert_matches_regex, which tests whether a string matches a given regex, causing a panic if it does not match.

CI Latest version Documentation License

[dev-dependencies]
assert_matches_regex = "0.1"

Example

use assert_matches_regex::assert_matches_regex;

assert_matches_regex!("Hello!", r"(?i)hello");

let data = "deadc0de";
assert_matches_regex!(data, "^[a-f0-9]$", "expected `{data}` to be a hex string");

License

Licensed under either of Apache License, Version 2.0 or MIT license at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in this crate by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Dependencies

~2–3MB
~53K SLoC