October 2013
Intermediate to advanced
368 pages
9h 20m
English
For our next test, we tackle the case where two adjacent letters encode to the same digit. Per Soundex rule #3, such duplicate letters get encoded as a single digit. The rule also states that it applies to the first letter. Let’s deal with the first case now and worry about the first letter next.
| c2/29/SoundexTest.cpp | |
| | TEST_F(SoundexEncoding, CombinesDuplicateEncodings) { |
| | ASSERT_THAT(soundex.encode("Abfcgdt"), Eq("A123")); |
| | } |
That’s a confusing test! To understand why Abfcgdt encodes to A123, we have to know that b and f both encode to 1, c and g both encode to 2, and d and t both encode to 3. We can learn these facts from reading other tests, such as ReplacesConsonantsWithAppropriateDigits, ...