The main thing I've noticed is the usage of int
type to represent characters. Characters are stored in the memory as numbers but as for testing I would expect to see char
in theirits human readable form. For example:
public void randomUpperCaseLetter() { char letter = new RandomLetter().generate(); int upperCaseAAsciiCode = 65; int upperCaseZAsciiCode = 90; assertTrue(letter >= upperCaseAAsciiCode && letter <= upperCaseZAsciiCode); }
should be written for clarity as
public void randomUpperCaseLetter() {
char letter = new RandomLetter().generate();
assertTrue(letter >= 'A' && letter <= 'Z' );
}
To better test the generating letter functionality, I would call generate
method multiple timetimes (possibly in a loop) to generate more letters.
For the second test method, it seems to be unnecessary. The letter 'A' will always have ASCII character code 65 and there is no need to test it.
public void compareCharactersWithAsciiCodes() {
assertEquals(65, 'A');
:
}
public void compareCharactersWithAsciiCodes() { assertEquals(65, 'A'); : }