Added more name conflicts to NameMapper unit test

The extended setup of the NameMapper unit test demonstrates (by the fact
that this change doesn't break the tests that check the stderr) that
certain naming conflicts escape NameMapper's attention.
This commit is contained in:
Veloman Yunkan 2024-03-05 18:21:37 +04:00 committed by Matthieu Gautier
parent 5e669cd65c
commit 4e64d26ede
1 changed files with 24 additions and 0 deletions

View File

@ -14,6 +14,12 @@ const char libraryXML[] = R"(
<book id="03" path="/data/ZERO thrêë.zim"> </book>
<book id="04-2021-10" path="/data/zero_four_2021-10.zim"></book>
<book id="04-2021-11" path="/data/zero_four_2021-11.zim"></book>
<book id="05-a" path="/data/zero_five-a.zim" name="zero_five"></book>
<book id="05-b" path="/data/zero_five-b.zim" name="zero_five"></book>
<book id="06+" path="/data/zërô + SIX.zim"></book>
<book id="06plus" path="/data/zero_plus_six.zim"></book>
<book id="07-super" path="/data/zero_seven.zim"></book>
<book id="07-sub" path="/data/subdir/zero_seven.zim"></book>
</library>
)";
@ -70,12 +76,30 @@ void checkUnaliasedEntriesInNameMapper(const kiwix::NameMapper& nm)
EXPECT_EQ("zero_three", nm.getNameForId("03"));
EXPECT_EQ("zero_four_2021-10", nm.getNameForId("04-2021-10"));
EXPECT_EQ("zero_four_2021-11", nm.getNameForId("04-2021-11"));
EXPECT_EQ("zero_five-a", nm.getNameForId("05-a"));
EXPECT_EQ("zero_five-b", nm.getNameForId("05-b"));
// unreported conflict
EXPECT_EQ("zero_plus_six", nm.getNameForId("06+"));
EXPECT_EQ("zero_plus_six", nm.getNameForId("06plus"));
// unreported conflict
EXPECT_EQ("zero_seven", nm.getNameForId("07-super"));
EXPECT_EQ("zero_seven", nm.getNameForId("07-sub"));
EXPECT_EQ("01", nm.getIdForName("zero_one"));
EXPECT_EQ("02", nm.getIdForName("zero_two"));
EXPECT_EQ("03", nm.getIdForName("zero_three"));
EXPECT_EQ("04-2021-10", nm.getIdForName("zero_four_2021-10"));
EXPECT_EQ("04-2021-11", nm.getIdForName("zero_four_2021-11"));
// book name doesn't participate in name mapping
EXPECT_THROW(nm.getIdForName("zero_five"), std::out_of_range);
EXPECT_EQ("05-a", nm.getIdForName("zero_five-a"));
EXPECT_EQ("05-b", nm.getIdForName("zero_five-b"));
EXPECT_EQ("06plus", nm.getIdForName("zero_plus_six"));
EXPECT_EQ("07-super", nm.getIdForName("zero_seven"));
}
TEST_F(NameMapperTest, HumanReadableNameMapperWithoutAliases)