Extracted testSpellingCorrections()

... so that it can be reused in a test where an existing spellings
database is opened.
This commit is contained in:
Veloman Yunkan
2025-10-04 17:45:11 +04:00
parent 286649e8c3
commit e0491adc85

View File

@@ -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);
}