Skip to content

Latest commit

 

History

History
25 lines (20 loc) · 588 Bytes

testsuite.md

File metadata and controls

25 lines (20 loc) · 588 Bytes

Provides some functions to help unittesting.

bool eq(A,B)( in A a, in B b );

unittest
{
    assert( eq(1,1.0) );
    assert( eq("hello","hello"w) );
}

for floating points in eq uses bool eq_approx(A,B,E)( in A a, in B b, in E eps );

bool mustExcept(E=Exception)( void delegate() fnc, bool throwUnexpected=false ) if( is( E : Throwable ) )

unittest
{
    assert( mustExcept!Exception( { throw new Exception("test"); } ) );
    assert( !mustExcept!Exception( { throw new Throwable("test"); } ) );
    assert( !mustExcept!Exception( { auto a = 4; } ) );
}