dunit.toolkit

Assert toolkit for more expressive unit testing.

Many methods implement compile-time parameters (file, line) that are set at the call site. It is preferred that these parameters are ignored when using these methods.

Members

Functions

assertApprox
void assertApprox(A value, B target, long ulps = 10, string message = "Failed asserting approximately equal", string file = __FILE__, size_t line = __LINE__)

Assert that two floating point values are approximately equal.

assertApprox
void assertApprox(A value, B target, double epsilon, string message = "Failed asserting approximately equal", string file = __FILE__, size_t line = __LINE__)

Assert that two floating point values are approximately equal using an epsilon value.

assertCount
void assertCount(A array, ulong count, string message = "Failed asserting array count", string file = __FILE__, size_t line = __LINE__)

Assert that an array contains a particular value count.

assertEmpty
void assertEmpty(A array, string message = "Failed asserting empty array", string file = __FILE__, size_t line = __LINE__)

Assert that an array is empty.

assertEmpty
void assertEmpty(R range, string message = "Failed asserting empty range", string file = __FILE__, size_t line = __LINE__)

Assert that a range is empty.

assertEndsWith
void assertEndsWith(string value, string suffix, string message = "Failed asserting ends with", string file = __FILE__, size_t line = __LINE__)

Assert that a string ends with a particular string.

assertEqual
void assertEqual(A value, B target, string message = "Failed asserting equal", string file = __FILE__, size_t line = __LINE__)

Assert that two values are equal.

assertFalse
void assertFalse(T value, string message = "Failed asserting false", string file = __FILE__, size_t line = __LINE__)

Assert that a boolean value is false.

assertFalsey
void assertFalsey(T value, string message = "Failed asserting falsey", string file = __FILE__, size_t line = __LINE__)

Assert that a value evaluates as false.

assertGreaterThan
void assertGreaterThan(A value, B threshold, string message = "Failed asserting greater than", string file = __FILE__, size_t line = __LINE__)

Assert that a value is greater than a threshold value.

assertGreaterThanOrEqual
void assertGreaterThanOrEqual(A value, B threshold, string message = "Failed asserting greater than or equal", string file = __FILE__, size_t line = __LINE__)

Assert that a value is greater than or equal to a threshold value.

assertHasKey
void assertHasKey(A haystack, B needle, string message = "Failed asserting array has key", string file = __FILE__, size_t line = __LINE__)

Assert that an associative array contains a particular key.

assertHasValue
void assertHasValue(A haystack, B needle, string message = "Failed asserting array has value", string file = __FILE__, size_t line = __LINE__)

Assert that an array contains a particular value.

assertInstanceOf
void assertInstanceOf(B value, string message = "Failed asserting instance of", string file = __FILE__, size_t line = __LINE__)

Assert that a value is an instance of a type.

assertLessThan
void assertLessThan(A value, B threshold, string message = "Failed asserting less than", string file = __FILE__, size_t line = __LINE__)

Assert that a value is less than a threshold value.

assertLessThanOrEqual
void assertLessThanOrEqual(A value, B threshold, string message = "Failed asserting less than or equal", string file = __FILE__, size_t line = __LINE__)

Assert that a value is less than or equal to a threshold value.

assertMatchRegex
void assertMatchRegex(string value, string pattern, string message = "Failed asserting match to regex", string file = __FILE__, size_t line = __LINE__)

Assert that a string matches a regular expression.

assertNull
void assertNull(A value, string message = "Failed asserting null", string file = __FILE__, size_t line = __LINE__)

Assert that a value is null.

assertStartsWith
void assertStartsWith(string value, string prefix, string message = "Failed asserting starts with", string file = __FILE__, size_t line = __LINE__)

Assert that a string starts with a particular string.

assertThrow
void assertThrow(lazy B expression, string expressionMsg = null, string message = "Failed asserting throw", string file = __FILE__, size_t line = __LINE__)

Assert that an expression throws an exception.

assertTrue
void assertTrue(T value, string message = "Failed asserting true", string file = __FILE__, size_t line = __LINE__)

Assert that a boolean value is true.

assertTruthy
void assertTruthy(T value, string message = "Failed asserting truthy", string file = __FILE__, size_t line = __LINE__)

Assert that a value evaluates as true.

assertType
void assertType(B value, string message = "Failed asserting type", string file = __FILE__, size_t line = __LINE__)

Assert that a value is of a particular type.

Meta

License

MIT. See LICENSE for full details.