Skip to content

Commit

Permalink
Use assert_matches crate instead of ad-hoc macro
Browse files Browse the repository at this point in the history
  • Loading branch information
jix committed Dec 26, 2021
1 parent cafe3cd commit 71e74c9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 12 deletions.
3 changes: 3 additions & 0 deletions flussab-cnf/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,6 @@ categories = ["parser-implementations", "encoding"]
flussab = { version = "0.1.0", path = "../flussab" }
thiserror = "1.0.24"
num-traits = "0.2.14"

[dev-dependencies]
assert_matches = "1.5.0"
14 changes: 2 additions & 12 deletions flussab-cnf/src/cnf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -239,22 +239,12 @@ pub fn write_clause<L: Dimacs>(writer: &mut DeferredWriter, clause_lits: &[L]) {

#[cfg(test)]
mod tests {
use assert_matches::assert_matches;

use super::*;

type Result<T> = std::result::Result<T, ParseError>;

macro_rules! assert_matches {
($value:expr, $matches:pat) => {
let value = $value;
assert!(
matches!(&value, &$matches),
"{:?} does not match {}",
value,
stringify!($matches)
);
};
}

#[test]
fn empty() -> Result<()> {
let mut parser = Parser::<i32>::from_read("".as_bytes(), Config::default())?;
Expand Down

0 comments on commit 71e74c9

Please sign in to comment.