5.should.equal(5);
5.should.not.equal(6);
(new Object).should.not.equal(new Object);
auto obj = new Object;
obj.should.equal(obj);
obj.should.be(obj);
class SameyClass
{
override bool opEquals(Object o) { return true; }
}
(new SameyClass).should.not.be(new SameyClass);
(new SameyClass).should.equal(new SameyClass);
const string[int] hashmap1 = [1: "2", 5: "4"];
string[int] hashmap2 = null;
hashmap2[5] = "4";
hashmap2[1] = "2";
// TODO reliable way to produce a hash collision
// assert(hashmap1.keys != hashmap2.keys, "hash collision not found"); // make sure that ordering doesn't matter
hashmap1.should.equal(hashmap2);
hashmap2.should.equal(hashmap1);
import std.range : only;
5.only.should.equal([5]);
[5].should.equal(5.only);
5.only.should.not.equal(6.only);
5.only.should.not.equal([6]);
The word .equal tests for equality. It takes one parameter and terminates the phrase. Its parameter is the expected value for the left-hand side of the should phrase.