Skip to content

Commit b48f6fe

Browse files
More test points in Suggestion.titleEdgeCases unit-test
1 parent b2941cd commit b48f6fe

File tree

1 file changed

+41
-2
lines changed

1 file changed

+41
-2
lines changed

test/suggestion.cpp

Lines changed: 41 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -722,6 +722,17 @@ TEST(Suggestion, titleEdgeCases) {
722722
{ "toolongsingleword1", w64 },
723723
{ "toolongsingleword2", w65 },
724724

725+
// Handling of pseudo-words consisting exclusively of punctuation
726+
{ "winknsmilewithouttext", ";-)" }, // A punctuation-only title
727+
{ "winknsmilebothways", ";-) wink'n'smile" },
728+
{ "winknsmiletheotherwayaround", "wink'n'smile ;-)" },
729+
{ "smilinglongword", ";-) " + w65 },
730+
{ "winknsmilewithothernonwords", "~~ ;-) ~~" },
731+
732+
// Handling of stopwords
733+
{ "hasisastopword", "Kiwix has our support" },
734+
{ "titlemadeofonlystopwords", "He who has nothing" },
735+
725736
// Non edge cases
726737
{ "Stout", "About Rex Stout" },
727738
{ "Hangout", "Without a trout" },
@@ -755,8 +766,36 @@ TEST(Suggestion, titleEdgeCases) {
755766
EXPECT_SUGGESTED_TITLES(archive, "awordthatis",
756767
w64,
757768
"Is " + w64 + " too long?"
758-
// w65 and "Is " + w65 + " too long?" aren't included because w65 has
759-
// been ignored during indexing
769+
// The following results aren't included because w65 has been ignored
770+
// during indexing:
771+
// - w65
772+
// - "Is " + w65 + " too long?"
773+
// - ";-) " + w65
774+
);
775+
776+
EXPECT_SUGGESTED_TITLES(archive, ";-",
777+
";-)",
778+
// The following results aren't included because ";-)" isn't treated as a
779+
// term in the presence of anything else:
780+
// - ";-) wink'n'smile"
781+
// - "wink'n'smile ;-)"
782+
// - ";-) " + w65
783+
// - "~~ ;-) ~~"
784+
);
785+
786+
EXPECT_SUGGESTED_TITLES(archive, "win",
787+
";-) wink'n'smile",
788+
"wink'n'smile ;-)"
789+
);
790+
791+
EXPECT_SUGGESTED_TITLES(archive, "smile",
792+
/* nothing */ // smile in "wink'n'smile" isn't a separate term
793+
);
794+
795+
// stopwords are not ignored when indexing titles
796+
EXPECT_SUGGESTED_TITLES(archive, "has",
797+
"He who has nothing",
798+
"Kiwix has our support",
760799
);
761800
}
762801

0 commit comments

Comments
 (0)