shouldRunLess

Used to assert that expression should be run less duration

void
shouldRunLess
(
E
)
(
lazy E condition
,
in Duration time
,
in string message = null
,
in string file = __FILE__
,
in size_t line = __LINE__
)

Parameters

condition
Type: E

The run expression.

time
Type: Duration

The maximum duration or running.

message
Type: string

Exception message.

file
Type: string

The file name that the assert failed in. Should be left as default.

line
Type: size_t

The file line that the assert failed in. Should be left as default.

Throws

If expression run greater time, will throw an UnitTestException.

Examples

// Will throw an exception like "UnitTestException@example.d(6): Expected run time <1 seconds>, but run <2 seconds>
{Thread.sleep(2.seconds)}.shouldRunLess(1.seconds);

Meta