Crates.io | assert_matches |
lib.rs | assert_matches |
version | 1.5.0 |
source | src |
created_at | 2016-02-16 20:12:56.68643 |
updated_at | 2021-02-05 04:16:48.301552 |
description | Asserts that a value matches a pattern |
homepage | https://github.com/murarth/assert_matches |
repository | https://github.com/murarth/assert_matches |
max_upload_size | |
id | 4194 |
size | 25,859 |
Provides a macro, assert_matches
, which tests whether a value
matches a given pattern, causing a panic if the match fails.
#[macro_use] extern crate assert_matches;
#[derive(Debug)]
enum Foo {
A(i32),
B(i32),
}
let a = Foo::A(1);
assert_matches!(a, Foo::A(_));
assert_matches!(a, Foo::A(i) if i > 0);
To include in your project, only when tests are compiled, add the following to your Cargo.toml:
[dev-dependencies]
assert_matches = "1.5"
And add the following to your crate root:
#[cfg(test)] #[macro_use]
extern crate assert_matches;
assert_matches
is distributed under the terms of both the MIT license and the
Apache License (Version 2.0).
See LICENSE-APACHE and LICENSE-MIT for details.