Struct unit::Unit

source ·
pub struct Unit {}

Implementations§

source§

impl Unit

source

pub fn new() -> Unit

source

pub fn end(self) -> Result<(), ()>

source

pub fn ok( self, description: &str, callback: &dyn Fn() -> bool, success: &str, failure: &str, message: &str ) -> Unit

Check if a callback return true
  • description The test description
  • callback The callback to check
  • success The success message
  • failure The failure message
  • message The panic message
use std::env::consts::OS;
use unit::Unit;

fn is_linux()-> bool
{
    OS == "linux"
}

Unit::new()
.ok("Check if user use linux",&is_linux,"User use linux","User don't use linux","User must be use linux")
.end().expect("panic message");
source

pub fn ko( self, description: &str, callback: &dyn Fn() -> bool, success: &str, failure: &str, message: &str ) -> Unit

Check if a callback return false
  • description The test description
  • callback The callback to check
  • success The success message
  • failure The failure message
  • message The panic message
use std::env::consts::OS;
use unit::Unit;

fn is_windows()-> bool
{
    OS == "windows"
}

Unit::new()
.ko("Check if user use linux",&is_windows,"User use linux","User don't use linux","User must be use linux")
.end().expect("panic message");
source

pub fn equals<T: PartialEq>( self, description: &str, callback: &dyn Fn() -> T, expected: T, success: &str, failure: &str, message: &str ) -> Unit

Check if a callback is equals to expected value
  • description The test description
  • callback The callback to check
  • expected The callback expected result
  • success The success message
  • failure The failure message
  • message The panic message
use std::env::consts::OS;
use unit::Unit;

fn is_windows()-> bool
{
    OS == "windows"
}

Unit::new()
.equals("Check if user use linux",&is_windows,false,"User use linux","User don't use linux","User must be use linux")
.end().expect("panic message");
source

pub fn between<T: PartialOrd>( self, description: &str, callback: &dyn Fn() -> T, min: T, max: T, success: &str, failure: &str, message: &str ) -> Unit

Check if a callback return a expected value
  • description The test description
  • callback The callback to check
  • min The min value for the callback result
  • max The callback for the callback result
  • success The success message
  • failure The failure message
  • message The panic message
use std::env::consts::OS;
use unit::Unit;

fn is_windows()-> i32
{
    500
}

Unit::new()
.between("Check if user use linux",&is_windows,400,600,"User use linux","User don't use linux","User must be use linux")
.end().expect("panic message");
source

pub fn unequals<T: PartialEq>( self, description: &str, callback: &dyn Fn() -> T, unexpected: T, success: &str, failure: &str, message: &str ) -> Unit

Check if a callback are unequals to the expected value
  • description The test description
  • callback The callback to check
  • unexpected The callback unexpected result
  • success The success message
  • failure The failure message
  • message The panic message
use std::env::consts::OS;
use unit::Unit;

fn is_windows()-> bool
{
    OS == "windows"
}

Unit::new()
.unequals("Check if user use linux",&is_windows,true,"User use linux","User don't use linux","User must be use linux")
.end().expect("panic message");
source

pub fn inferior<T: PartialOrd>( self, description: &str, callback: &dyn Fn() -> T, expected: T, success: &str, failure: &str, message: &str ) -> Unit

Check if a callback return an inferior value to the expected value
  • description The test description
  • callback The callback to check
  • success The success message
  • failure The failure message
  • message The panic message
use std::env::consts::OS;
use unit::Unit;

fn is_windows()-> i32
{
    500
}

Unit::new()
.inferior("Check if user use linux",&is_windows,1000,"User use linux","User don't use linux","User must be use linux")
.end().expect("panic message");
source

pub fn superior<T: PartialOrd>( self, description: &str, callback: &dyn Fn() -> T, expected: T, success: &str, failure: &str, message: &str ) -> Unit

Check if a callback return a superior value to expected
  • description The test description
  • callback The callback to check
  • success The success message
  • failure The failure message
  • message The panic message
use std::env::consts::OS;
use unit::Unit;

fn is_windows()-> i32
{
    500
}

Unit::new()
.superior("Check if user use linux",&is_windows,400,"User use linux","User don't use linux","User must be use linux")
.end().expect("panic message");
source

pub fn not_empty( self, description: &str, expected: &fn() -> String, success: &str, failure: &str, message: &str ) -> Unit

Check if a callback return a not empty value
  • description The test description
  • callback The callback to check
  • success The success message
  • failure The failure message
  • message The panic message
use std::env::consts::OS;
use unit::Unit;

fn os()-> String
{
    OS.to_string()
}

Unit::new()
.not_empty("Check if we can detected os",&os,"We can detect os","We can't detect os","We must detect os")
.end().expect("panic message");
source

pub fn empty( self, description: &str, expected: fn() -> String, success: &str, failure: &str, message: &str ) -> Unit

Check if a callback return an empty value
  • description The test description
  • callback The callback to check
  • success The success message
  • failure The failure message
  • message The panic message
use std::env::consts::OS;
use unit::Unit;

fn os()-> String
{
   String::new()
}

Unit::new()
.empty("Check if we can detected os",os,"We can detect os","We can't detect os","We must detect os")
.end().expect("panic message");
source

pub fn exists( self, description: &str, paths: Vec<&str>, success: &str, failure: &str, message: &str ) -> Unit

Check if all paths given exists
  • description The test description
  • callback The callback to check
  • success The success message
  • failure The failure message
  • message The panic message
use std::env::consts::OS;
use unit::Unit;

fn is_windows()-> bool
{
    OS == "windows"
}

Unit::new()
.exists("Check if user use linux",vec!["/","/home"],"User use linux","User don't use linux","User must be use linux")
.end().expect("panic message");
source

pub fn theory<T: PartialEq>( self, description: &str, callback: &dyn Fn() -> T, expected: T, success: &str, failure: &str, message: &str ) -> Unit

Check if a callback return a expected value
  • description The test description
  • callback The callback to check
  • success The success message
  • failure The failure message
  • message The panic message
use std::env::consts::OS;
use unit::Unit;

fn is_windows()-> bool
{
    OS == "windows"
}

Unit::new()
.unequals("Check if user use linux",&is_windows,true,"User use linux","User don't use linux","User must be use linux")
.end().expect("panic message");
source

pub fn expect<T: PartialEq>( self, description: &str, callback: &dyn Fn() -> T, expected: T, success: &str, failure: &str, message: &str ) -> Unit

Check if a callback return a expected value
  • description The test description
  • callback The callback to check
  • success The success message
  • failure The failure message
  • message The panic message
use std::env::consts::OS;
use unit::Unit;

fn is_windows()-> bool
{
    OS == "windows"
}

Unit::new()
.expect("Check if user use linux",&is_windows,false,"User use linux","User don't use linux","User must be use linux")
.end().expect("panic message");
source

pub fn chaos<T: PartialEq>( self, description: &str, callback: &dyn Fn() -> T, unexpected: T, success: &str, failure: &str, message: &str ) -> Unit

Check if a callback return false
  • description The test description
  • callback The callback to check
  • success The success message
  • failure The failure message
  • message The panic message
use std::env::consts::OS;
use unit::Unit;

fn is_windows()-> bool
{
    OS == "windows"
}

Unit::new()
.unequals("Check if user use linux",&is_windows,true,"User use linux","User don't use linux","User must be use linux")
.end().expect("panic message");

Auto Trait Implementations§

§

impl RefUnwindSafe for Unit

§

impl Send for Unit

§

impl Sync for Unit

§

impl Unpin for Unit

§

impl UnwindSafe for Unit

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

const: unstable · source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
const: unstable · source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.