unittest + struct ctorю + nested mixin template + alias

ref2401 refactor24 at gmail.com
Tue May 7 08:33:25 PDT 2013


i'm using VisualD.

this assertion fails assert(msg == "Null reference message");
in my actual code instead of variable _message an exception is 
thrown if (obj is null) == true.
i'm using the unittest block to test exception throwing.

...
	this(T obj)
	{
		if (obj is null){
			throw new Exception("Null reference.");
		}
	}
...


unittest
{
	alias MyStruct!MyClass StructType;
	std.exception.assertThrown(StructType(null));	// Wrong assertion
}


More information about the Digitalmars-d-learn mailing list