dchip.util

Members

Aliases

assertEmpty
alias assertEmpty = assertProp!("empty", true)

Assert range isn't empty.

assertEqual
alias assertEqual = assertEquality!true

Unittest functions which give out a message with the failing expression.

assertEquals
alias assertEquals = assertEqual

Common mispelling.

assertNotEmpty
alias assertNotEmpty = assertProp!("empty", false)

Assert range isn't empty.

assertNotEqual
alias assertNotEqual = assertEquality!false

Common mispelling.

Functions

_makeEnumAliases
string _makeEnumAliases()

Export all enum members as aliases. This allows enums to be used as types and allows its members to be used as if they're defined in module scope.

assertErrorsWith
void assertErrorsWith(lazy E expr, string msg, string file = __FILE__, size_t line = __LINE__)

Verify that calling expr throws and contains the exception message msg.

enquote
string enquote(T arg)

Return string representation of argument. If argument is already a string or a character, enquote it to make it more readable.

getException
Exc getException(lazy E expr, string file = __FILE__, size_t line = __LINE__)

Return the exception of type Exc that is expected to be thrown when expr is evaluated.

getExceptionMsg
string getExceptionMsg(lazy E expr, string file = __FILE__, size_t line = __LINE__)

Return the exception message of an exception. If no exception was thrown, then a new exception is thrown to notify the user of the missing exception.

require
T require(T value, Args args)

Similar to enforce, except it can take a formatting string as the second argument. Note: Until Issue 8687 is fixed, file and line have to be compile-time arguments, which might create template bloat.

safeCast
T safeCast(S s)

See: https://github.com/slembcke/Chipmunk2D/issues/56

Mixin templates

_ExportEnumMembers
mixin template _ExportEnumMembers(E)

Export all enum members as aliases. This allows enums to be used as types and allows its members to be used as if they're defined in module scope.

Templates

assertOp
template assertOp(string op)

Useful template to generate an assert check function

enforceEx
template enforceEx(E)

An overload of enforceEx which allows constructing the exception with the arguments its ctor supports. The ctor's last parameters must be a string (file) and size_t (line).

Meta