Rule #1 says to drop all occurrences of vowels and the letters w, h, and y. For lack of a better name, we’ll refer to these as vowel-like letters.
c2/28/SoundexTest.cpp | |
| TEST_F(SoundexEncoding, IgnoresVowelLikeLetters) { |
| ASSERT_THAT(soundex.encode("Baeiouhycdl"), Eq("B234")); |
| } |
The test passes without us adding a lick of production code, because encodedDigit answers an empty string if the letter to be encoded wasn’t found. Any vowels thus encode to the empty string, which gets harmlessly appended.
A test that passes with no change to your classes is always cause for humility and pause (see Getting Green on Red). Ask yourself, “What might I have done differently?”
If a stream of subsequent tests continues to pass, consider reverting your effort. You’re likely taking too-large steps, and you likely won’t find as much benefit in TDD. In our case, we could have written a test that demonstrates what happens for any unrecognized characters and at that point chosen to have it return the same character instead of the empty string.
18.118.139.224