October 2013
Intermediate to advanced
368 pages
9h 20m
English
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 Section 3.5, Getting Green on Red). Ask yourself, “What might I have done differently?”
If a stream of subsequent ...