assertCount

Assert that an array contains a particular value count.

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

Parameters

array A

The array to interogate.

count ulong

The amount of values the array should hold.

message string

The error message to display.

file string

The file name where the error occurred. The value is added automatically at the call site.

line size_t

The line where the error occurred. The value is added automatically at the call site.

Throws

DUnitAssertError if the assertation fails.

Examples

int[string] associativeArray;
int[] dynamicArray;
string string_;

associativeArray.assertCount(0);
dynamicArray.assertCount(0);
string_.assertCount(0);
[].assertCount(0);

"Hello".assertCount(5);
[1, 2, 3, 4].assertCount(4);
["foo", "bar", "baz", "qux"].assertCount(4);
[["foo", "bar"], ["baz", "qux"]].assertCount(2);
["foo":1, "bar":2, "baz":3, "qux":4].assertCount(4);

// Assert a DUnitAssertError is thrown if assertCount fails.
associativeArray.assertCount(1).assertThrow!(DUnitAssertError)("Failed asserting array count");

Meta