toBeEmpty

Expects that the subject of this expectation (a CharSequence) CharSequence.kotlin.text.isEmpty.

Return

an Expect for the subject of this expectation.

Since

0.17.0

Samples

expect("").toBeEmpty()

fails {
    expect("XYZ").toBeEmpty()
}

Expects that the subject of this expectation (a Collection) is an empty Collection.

Return

an Expect for the subject of this expectation.

Since

0.17.0

Samples

expect(emptyList<Int>()).toBeEmpty()

fails {
    expect(listOf(1, 2, 3)).toBeEmpty()
}

fun <T : Map<*, *>> Expect<T>.toBeEmpty(): Expect<T>(source)

Expects that the subject of this expectation (a Map) is an empty Map.

Return

an Expect for the subject of this expectation.

Since

0.17.0

Samples

expect(emptyMap<Int, String>()).toBeEmpty()

fails { // because the map is not empty
    expect(mapOf(1 to "a")).toBeEmpty()
}

Expects that the subject of this expectation (an Optional) is empty (not present).

Shortcut for more or less something like feature(Optional<T>::isEmpty) { toEqual(true) } depends on the underlying implementation though.

Return

an Expect for the subject of this expectation.

Since

0.17.0

Samples

expect(Optional.empty<String>()).toBeEmpty()

fails {
    expect(Optional.of(1)).toBeEmpty()
}