1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
use std::fmt;
use thiserror::Error;

#[derive(Debug, Error)]
pub enum Error {
    #[error("{0}")]
    VerificationFailed(String),
}

pub fn assert_equals<A: fmt::Debug + PartialEq>(
    left: &A,
    right: &A,
    info: &str,
) -> Result<(), Error> {
    if left != right {
        return Err(Error::VerificationFailed(format!(
            "{}. {:?} vs {:?}",
            info, left, right
        )));
    }
    Ok(())
}

pub fn assert(statement: bool, info: &str) -> Result<(), Error> {
    if !statement {
        return Err(Error::VerificationFailed(info.to_string()));
    }
    Ok(())
}