assertEmpty

Assert that an array is empty.

  1. void assertEmpty(A array, string message, string file, size_t line)
    void
    assertEmpty
    (
    A
    )
    (,
    string message = "Failed asserting empty array"
    ,
    string file = __FILE__
    ,
    size_t line = __LINE__
    )
    if (
    isArray!(A) ||
    isAssociativeArray!(A)
    )
  2. void assertEmpty(R range, string message, string file, size_t line)

Parameters

array A

The array to interogate.

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.assertEmpty();
dynamicArray.assertEmpty();
string_.assertEmpty();
[].assertEmpty();

// Assert a DUnitAssertError is thrown if assertEmpty fails.
[1].assertEmpty().assertThrow!(DUnitAssertError)("Failed asserting empty array");

Meta