diff --git a/test/book.cpp b/test/book.cpp index 55de4e2df..b69b8cf40 100644 --- a/test/book.cpp +++ b/test/book.cpp @@ -15,11 +15,19 @@ struct XMLDoc : pugi::xml_document } // unnamed namespace +#if _WIN32 +# define DATA_ABS_PATH "C:\\data\\zim" +# define ZARA_ABS_PATH "C:\\data\\zim\\zara.zim" +#else +# define DATA_ABS_PATH "/data/zim" +# define ZARA_ABS_PATH "/data/zim/zara.zim" +#endif + TEST(BookTest, updateFromXMLTest) { const XMLDoc xml(R"( getBookById("0d0bcd57-d3f6-cb22-44cc-a723ccb4e1b2"); - EXPECT_EQ("/data/zimfiles/unittest.zim", book.getPath()); + EXPECT_EQ(ZIM_ABS_PATH, book.getPath()); EXPECT_EQ("https://example.com/zimfiles/unittest.zim", book.getUrl()); EXPECT_EQ("Unit Test", book.getTitle()); EXPECT_EQ("Wikipedia articles about unit testing", book.getDescription()); diff --git a/test/name_mapper.cpp b/test/name_mapper.cpp index 74fecf481..371cc9d5f 100644 --- a/test/name_mapper.cpp +++ b/test/name_mapper.cpp @@ -7,6 +7,23 @@ namespace { +#if _WIN32 +const char libraryXML[] = R"( + + + + + + + + + + + + + +)"; +#else const char libraryXML[] = R"( @@ -22,6 +39,7 @@ const char libraryXML[] = R"( )"; +#endif class NameMapperTest : public ::testing::Test { public: @@ -61,7 +79,22 @@ public: operator std::string() const { return buffer.str(); } }; +#if _WIN32 +const std::string ZERO_FOUR_NAME_CONFLICT_MSG = + "Path collision: 'C:\\data\\zero_four_2021-10.zim' and" + " 'C:\\data\\zero_four_2021-11.zim' can't share the same URL path 'zero_four'." + " Therefore, only 'C:\\data\\zero_four_2021-10.zim' will be served.\n"; +const std::string ZERO_SIX_NAME_CONFLICT_MSG = + "Path collision: 'C:\\data\\zërô + SIX.zim' and " + "'C:\\data\\zero_plus_six.zim' can't share the same URL path 'zero_plus_six'." + " Therefore, only 'C:\\data\\zërô + SIX.zim' will be served.\n"; + +const std::string ZERO_SEVEN_NAME_CONFLICT_MSG = + "Path collision: 'C:\\data\\subdir\\zero_seven.zim' and" + " 'C:\\data\\zero_seven.zim' can't share the same URL path 'zero_seven'." + " Therefore, only 'C:\\data\\subdir\\zero_seven.zim' will be served.\n"; +#else const std::string ZERO_FOUR_NAME_CONFLICT_MSG = "Path collision: '/data/zero_four_2021-10.zim' and" " '/data/zero_four_2021-11.zim' can't share the same URL path 'zero_four'." @@ -76,6 +109,7 @@ const std::string ZERO_SEVEN_NAME_CONFLICT_MSG = "Path collision: '/data/subdir/zero_seven.zim' and" " '/data/zero_seven.zim' can't share the same URL path 'zero_seven'." " Therefore, only '/data/subdir/zero_seven.zim' will be served.\n"; +#endif // Name conflicts in the default mode (without the --nodatealiases is off const std::string DEFAULT_NAME_CONFLICTS = ZERO_SIX_NAME_CONFLICT_MSG