Right pad string with spaces

In this example we will demonstrate how to pad the end of a string with spaces. We choose a random string of warhawks calling padRight passing in length of the final string and the value to place at the end. We will check if the padded string has the length of ten. A similar example showing how to pad a string with trailing spaces in java guava or apache commons.

@Test
void right_pad_string_with_spaces() {

    def warhawksPadded = "Warhawks".padRight(10, " ")

    assert "Warhawks  " == warhawksPadded
    assert 10 == warhawksPadded.length()
}