Simplify count_words, add trim_and_count_words

The original count_words function (before it was put into utils::) also trimmed
comments. For compatibility this behaviour was retained at first. However, due
to the name the trimming is not immediatly apparent and many times not
wanted.

Therefore, this commit replaces count_words with an implementation that
just does what it says. If a comment should be trimmed there is a
trim_comment function. For convenience, a trim_and_count_words function was
added and is now used where the old behaviour was needed.
This commit is contained in:
Richard Berger
2020-06-04 10:35:36 -04:00
parent 3c6ce73ccf
commit 9291d2a9d7
14 changed files with 40 additions and 20 deletions

View File

@ -25,7 +25,11 @@ TEST(Utils, trim_comment) {
}
TEST(Utils, count_words) {
ASSERT_EQ(utils::count_words("some text # comment"), 2);
ASSERT_EQ(utils::count_words("some text # comment"), 4);
}
TEST(Utils, trim_and_count_words) {
ASSERT_EQ(utils::trim_and_count_words("some text # comment"), 2);
}
TEST(Utils, valid_integer1) {