assertNull

Assert that a value is null.

void
assertNull
(
A
)
(,
string message = "Failed asserting null"
,
string file = __FILE__
,
size_t line = __LINE__
)
if (
A.init is null
)

Parameters

value A

The value to assert as null.

message string

The error message to display.

file string

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

line size_t

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

Throws

DUnitAssertError if the assertation fails.

Examples

class T {}

string foo;
int[] bar;
T t;

foo.assertNull();
bar.assertNull();
t.assertNull();
null.assertNull();

// Assert a DUnitAssertError is thrown if assertNull fails.
"foo".assertNull().assertThrow!(DUnitAssertError)("Failed asserting null");

Meta