When editing text files, like source code, one often happens to add spurious spaces and tabs in the end of each line. Instead of pressing the "End" key at each line and removing those invisible characters manually, a simple algorithm to remove them automatically at the press of a button could be used. Using Test-Driven Development, build a class or function that, given an input string, produces a right-trimmed output string. Here are some tests that you could write:
|