Fluid
Summary
fluid
is an human readable test library.
The current goals of this crate are:
- Easily readable tests: they should be read like english sentences.
- Nice and understandable error messages.
- Provide the most possible useful assertions for common cases:
numbers,
Iterator
s,Option
s,Result
s, etc.
How to use it
Add the crate in your Cargo.toml
:
# Do not use in crate build, only in test
[]
= "0.1"
and in you main file:
extern crate fluid;
use *;
Examples
Simple equality
use *;
theory!.should.be_equal_to;
Negation
use *;
theory!.should.not.be_equal_to;
Explanation
use *;
theory!.should.be_equal_to
.because;
Nice error message
use *;
let my_result: = Err; //Oops
theory!.should.not.be_an_error
.and.should.contain
.because;
Displays:
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
Floats precision
use *;
theory!.should.be_equal_to.with_precision;
Result::Err
use *;
let parse_error = match "?". ;
let result = "two".;
theory!.should.be_an_error
.and.should.be_this_error;
Iterator
s
use *;
theory!.should.contain;
theory!.should.not.contain;
theory!.should.not.contain;