assertEquals

Asserts that the values are equal.

  1. void assertEquals(T expected, U actual, string msg, string file, size_t line)
  2. void assertEquals(T expected, U actual, string msg, string file, size_t line)
  3. void assertEquals(T expected, U actual, string msg, string file, size_t line)
    void
    assertEquals
    (
    T
    U
    )
    (,,
    lazy string msg = null
    ,
    string file = __FILE__
    ,
    size_t line = __LINE__
    )
    if (
    !isSomeString!T &&
    !isFloatingPoint!T
    &&
    !isFloatingPoint!U
    )

Throws

AssertException otherwise

Examples

assertEquals(42, 42);

auto exception = expectThrows!AssertException(assertEquals(42, 24));

assertEquals("expected: <42> but was: <24>", exception.msg);
Object foo = new Object();
Object bar = null;

assertEquals(foo, foo);
assertEquals(bar, bar);

auto exception = expectThrows!AssertException(assertEquals(foo, bar));

assertEquals("expected: <object.Object> but was: <null>", exception.msg);

Meta