Add unit test.

This commit is contained in:
Sönke Ludwig 2019-10-25 14:13:30 +02:00
parent d6d480b647
commit b037967ed0

View file

@ -479,6 +479,23 @@ unittest { // alignment
else assert((cast(ubyte*)&s3.vValue() - cast(ubyte*)&s3) % 4 == 0);
}
unittest { // toString
import std.conv : to;
static struct NoCopy {
@disable this(this);
string toString() const { return "foo"; }
}
union U { Void empty; int i; NoCopy noCopy; }
TaggedUnion!U val;
assert(val.to!string == "empty");
val.setI(42);
assert(val.to!string == "(i: 42)");
val.setNoCopy(NoCopy.init);
assert(val.to!string == "(noCopy: foo)");
}
/** Dispatches the value contained on a `TaggedUnion` to a set of visitors.