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

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 1.assertType!(int)();
2 "foo".assertType!(string)();
3 ["bar"].assertType!(string[])();
4 ['a'].assertType!(char[])();
5 
6 // Assert a DUnitAssertError is thrown if assertType fails.
7 false.assertType!(string)().assertThrow!(DUnitAssertError)("Failed asserting type");

Meta