Dropping Vowels

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 ...

Get Modern C++ Programming with Test-Driven Development now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.