assertType

Assert that a value is of a particular type.

void
assertType
(
A
B
)
(,
string message = "Failed asserting type"
,
string file = __FILE__
,
size_t line = __LINE__
)

Parameters

value B

The value used during the assertion.

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

1.assertType!(int)();
"foo".assertType!(string)();
["bar"].assertType!(string[])();
['a'].assertType!(char[])();

// Assert a DUnitAssertError is thrown if assertType fails.
false.assertType!(string)().assertThrow!(DUnitAssertError)("Failed asserting type");

Meta