assertTruthy

Assert that a value evaluates as true.

void
assertTruthy
(
T
)
(
,
string message = "Failed asserting truthy"
,
string file = __FILE__
,
size_t line = __LINE__
)

Parameters

value
Type: T

The value used during the assertion.

message
Type: string

The error message to display.

file
Type: string

The file name where the error occurred. The value is added automatically at the call site.

line
Type: size_t

The line where the error occurred. The value is added automatically at the call site.

Throws

DUnitAssertError if the assertation fails.

Examples

1 true.assertTruthy();
2 ["foo"].assertTruthy();
3 1.assertTruthy();
4 
5 // Assert a DUnitAssertError is thrown if assertTruthy fails.
6 false.assertTruthy().assertThrow!(DUnitAssertError)("Failed asserting truthy");

Meta