Crates.io | shoulds |
lib.rs | shoulds |
version | 0.1.6 |
source | src |
created_at | 2021-12-12 16:25:11.777722 |
updated_at | 2022-02-05 01:33:00.122422 |
description | An intuitive and simple library for writing test assertions in a natural and fluent language. |
homepage | |
repository | https://github.com/tarrball/shoulds/ |
max_upload_size | |
id | 496617 |
size | 15,427 |
shoulds is a Shouldly-inspired test assertion library for testing Rust.
should_be
should_be_greater_than
should_be_greater_than_or_equal_to
should_be_less_than
should_be_less_than_or_equal_to
should_contain
should_not_contain
should_be_false
should_be_true
should_be_error
should_be_ok
I'll add more assertions along the way as the need arises.
Cargo.toml
:
[dev-dependencies]
shoulds = "0.1.6"
src/lib.rs
:
fn add(a: i32, b: i32) -> i32 {
a + b
}
fn concat(a: &String, b: &String) -> String {
format!("{}{}", a, b)
}
#[cfg(test)]
mod tests {
use crate::{add, concat};
use shoulds::*;
#[test]
fn add_adds_params_together() {
let result = add(40, 2);
result.should_be(42)
}
#[test]
fn concat_concats_strings_together() {
let result = concat(&"Hello, ".to_string(), &"world!".to_string());
result.should_be("Hello, world!".to_string());
}
}