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

assert_matches_regex

Macro for asserting that a string matches a regex

1 unstable release

new 0.1.0 Nov 18, 2024

#259 in Testing

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.2–3MB
~55K SLoC