fluid
is an human readable test library.
The current goals of this crate are:
Iterator
s, Option
s, Result
s, etc.Add the crate in your Cargo.toml
:
```toml
[dev-dependencies] fluid = "0.1" ```
Reference the crate in your main file:
```rust
```
Import the crate content in scope of your tests file:
rust
use fluid::*;
rust
theory!(1 + 1).should().be_equal_to(2);
rust
theory!(1 + 1).should().not().be_equal_to(10);
rust
theory!(1 + 1).should().be_equal_to(2)
.because("this is basic arithmetic");
rust
let my_result: Result<i32, ()> = Err(()); //Oops
theory!(my_result).should().not().be_an_error()
.and_should().contain(42)
.because("I must have the answer");
Displays:
```none The test failed at src/tests.rs:76: 'my_result' should not have been an error But it is: 'Err(())'
'my_result' should have contain '42'
But it does not.
This test should have pass because I must have the answer ```
rust
theory!(1.).should().be_equal_to(1.01).with_precision(0.1);
Result::Err
rust
let parse_error = match "?".parse::<i32>() {
Ok(_) => unimplemented!(),
Err(e) => e,
};
let result = "two".parse::<i32>();
theory!(result).should().be_an_error()
.and_should().be_this_error(parse_error);
Iterator
s```rust
fn error(e: bool) -> Result
theory!(error(false)).should().contain(0); theory!(error(true)).should().not().contain(0); theory!(&[1, 2, 3]).should().not().contain(&0); ```