unit-testing 0.2.1

A unit testing library
Documentation
unit-testing-0.2.1 has been yanked.

Lib unit

To run unit test for your rust applications

Installation

cargo add unit-testing

Usage

use crate::zuu::Unit;

fn kool() -> bool
{
    return false;
}

fn look() -> bool
{
    return true;
}

fn f() -> i32
{
    return 1;
}

fn theorem() -> bool
{
    return 4 * 4 + 3 * 3 == 5 * 5;
}

fn s() -> i32
{
    return 0;
}

fn status(u: Unit) -> Unit
{
    return u.failure(&f).success(&s);
}

fn diff(u: Unit) -> Unit
{
    return u.unequals(&f, 2).different("a", "b");
}

fn files(u: Unit) -> Unit
{
    return u.exist(".");
}

fn numbers(u: Unit) -> Unit
{
    return u.equals(&s, 0).equals(&f, 1).unequals(&f, 2).between(&s, -1, 10).superior(&f, 0).inferior(&f, 10);
}

fn test_string(u: Unit) -> Unit
{
    let phrase = String::from("The humanity develop the linux kernel.");
    return u.empty("").not_empty(" ").identical(&phrase, "The humanity develop the linux kernel.").contains(&phrase, "linux").begin(&phrase, "The").finnish(&phrase, "kernel.");
}

fn boolean(u: Unit) -> Unit
{
    return u.ok(&look).ko(&kool);
}

fn main() -> i32
{
    Unit::new("Test the unit framework");
    u.describe("Test all boolean", &boolean)
        .describe("Test numbers", &numbers)
        .describe("Test success and failure", &status)
        .describe("Test differences", &diff)
        .describe("Test string", &test_string)
        .describe("Test files", &files)
        .theory("Test pythagore", &theorem, true)
    .end();
}

Run the test

cargo run