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
Type: A

The value to assert as null.

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 class T {}
2 
3 string foo;
4 int[] bar;
5 T t;
6 
7 foo.assertNull();
8 bar.assertNull();
9 t.assertNull();
10 null.assertNull();
11 
12 // Assert a DUnitAssertError is thrown if assertNull fails.
13 "foo".assertNull().assertThrow!(DUnitAssertError)("Failed asserting null");

Meta