From 4e64d26edeedb5290e258cd10504d81767573c48 Mon Sep 17 00:00:00 2001 From: Veloman Yunkan Date: Tue, 5 Mar 2024 18:21:37 +0400 Subject: [PATCH] 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. --- test/name_mapper.cpp | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/test/name_mapper.cpp b/test/name_mapper.cpp index b427ec5e..d972bfba 100644 --- a/test/name_mapper.cpp +++ b/test/name_mapper.cpp @@ -14,6 +14,12 @@ const char libraryXML[] = R"( + + + + + + )"; @@ -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)