cpAssertSoft

If the CHIP_ENABLE_WARNINGS version is set, throw a DChipError if condition is false.

void
cpAssertSoft
(
string file = __FILE__
size_t line = __LINE__
E
Args...
)
(
lazy E condition
,
lazy string expr
,
lazy Args args
)

Examples

import std.exception : assertNotThrown;
import dchip.util : assertErrorsWith;

int iteration = 10;
int WARN_GJK_ITERATIONS = 10;

version (CHIP_ENABLE_WARNINGS)
{
    cpAssertSoft(iteration < WARN_GJK_ITERATIONS, "iteration < WARN_GJK_ITERATIONS")
        .assertErrorsWith(`Error: Requirement failed. Failed condition: "iteration < WARN_GJK_ITERATIONS".`);

    assertNotThrown!DChipError(cpAssertSoft(iteration == WARN_GJK_ITERATIONS,
                                           "iteration == WARN_GJK_ITERATIONS"));
}
else
{
    assertNotThrown!DChipError(cpAssertSoft(iteration < WARN_GJK_ITERATIONS,
                                           "iteration < WARN_GJK_ITERATIONS"));
}

Meta