Skip to content

Type Operations

Test type properties with these assertions.

beNull

Asserts that a value is null. Works with any nullable type — pointers, delegates, classes, as well as null strings, arrays, and associative arrays. An empty (but non-null) string or array is not considered null.

void delegate() action = null;
expect(action).to.beNull();
string s = null;
expect(s).to.beNull();
expect("").to.not.beNull();

Negation

expect({ /* something */ }).to.not.beNull();

instanceOf

Asserts that an object is an instance of a specific class or interface.

class Animal {}
class Dog : Animal {}
auto dog = new Dog();
expect(dog).to.be.instanceOf!Dog;
expect(dog).to.be.instanceOf!Animal;

Negation

class Cat : Animal {}
expect(dog).to.not.be.instanceOf!Cat;