mirror of
https://github.com/kiwix/libkiwix.git
synced 2025-12-23 14:38:01 -05:00
Extracted testSpellingCorrections()
... so that it can be reused in a test where an existing spellings database is opened.
This commit is contained in:
@@ -42,17 +42,14 @@ protected:
|
||||
}
|
||||
};
|
||||
|
||||
void testSpellingCorrections(const kiwix::SpellingsDB& spellingsDB)
|
||||
{
|
||||
#define EXPECT_SPELLING_CORRECTION(query, maxSuggestions, parenthesizedExpectedResult) \
|
||||
EXPECT_EQ( \
|
||||
spellingsDB.getSpellingCorrections(query, maxSuggestions), \
|
||||
std::vector<std::string> parenthesizedExpectedResult \
|
||||
)
|
||||
|
||||
TEST_F(SpellingCorrectionTest, allInOne)
|
||||
{
|
||||
const auto archive = zim::Archive("./test/spelling_correction_test.zim");
|
||||
kiwix::SpellingsDB spellingsDB(archive, TEST_DB_PATH);
|
||||
|
||||
EXPECT_SPELLING_CORRECTION("", 1, ({}));
|
||||
|
||||
EXPECT_SPELLING_CORRECTION("geflekt", 1, ({"gefleckt"}));
|
||||
@@ -171,3 +168,10 @@ TEST_F(SpellingCorrectionTest, allInOne)
|
||||
// EXPECT_SPELLING_CORRECTION("Kung", 2, ({"King", "Kong"}));
|
||||
EXPECT_THROW(spellingsDB.getSpellingCorrections("Kung", 2), std::runtime_error);
|
||||
}
|
||||
|
||||
TEST_F(SpellingCorrectionTest, allInOne)
|
||||
{
|
||||
const auto archive = zim::Archive("./test/spelling_correction_test.zim");
|
||||
kiwix::SpellingsDB spellingsDB(archive, TEST_DB_PATH);
|
||||
testSpellingCorrections(spellingsDB);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user