Selector splitting: don't split selectors in the middle of whitelisted "multi-words".

Swift SVN r16016
This commit is contained in:
Doug Gregor
2014-04-07 19:17:23 +00:00
parent f6a196f700
commit 49387beb25
7 changed files with 194 additions and 10 deletions

View File

@@ -73,3 +73,26 @@ TEST(ToSentencecaseTest, Words) {
EXPECT_EQ(camel_case::toSentencecase("URL", scratch), "URL");
EXPECT_EQ(camel_case::toSentencecase("", scratch), "");
}
TEST(MultiWordsTest, Match) {
camel_case::MultiWordMap multiWords;
multiWords.insert("attributed", "string");
multiWords.insert("table", "view");
multiWords.insert("table", "view", "controller");
multiWords.insert("table", "top");
auto words1 = camel_case::getWords("createTableView");
EXPECT_EQ(*multiWords.match(words1.rbegin(), words1.rend()), "Table");
auto words2 = camel_case::getWords("createTableViewController");
EXPECT_EQ(*multiWords.match(words2.rbegin(), words2.rend()), "Table");
auto words3 = camel_case::getWords("createSubview");
EXPECT_EQ(*multiWords.match(words3.rbegin(), words3.rend()), "Subview");
auto words4 = camel_case::getWords("addView");
EXPECT_EQ(*multiWords.match(words4.rbegin(), words4.rend()), "View");
auto words5 = camel_case::getWords("insertAttributedString");
EXPECT_EQ(*multiWords.match(words5.rbegin(), words5.rend()), "Attributed");
}