@@ -9,6 +9,12 @@ namespace Misc::ResourceHelpers
99 {
1010 using namespace ::testing;
1111
12+ constexpr VFS::Path::NormalizedView sound (" sound" );
13+ constexpr VFS::Path::NormalizedView textures (" textures" );
14+ constexpr VFS::Path::NormalizedView bookart (" bookart" );
15+ constexpr VFS::Path::ExtensionView mp3 (" mp3" );
16+ constexpr VFS::Path::ExtensionView b (" b" );
17+
1218 TEST (MiscResourceHelpersCorrectSoundPath, shouldKeepWavExtensionIfExistsInVfs)
1319 {
1420 constexpr VFS::Path::NormalizedView path (" sound/foo.wav" );
@@ -25,112 +31,91 @@ namespace Misc::ResourceHelpers
2531
2632 TEST (MiscResourceHelpersCorrectSoundPath, shouldKeepWavExtensionIfBothExistsInVfs)
2733 {
28- constexpr VFS::Path::NormalizedView wav (" sound/foo.wav" );
29- constexpr VFS::Path::NormalizedView mp3 (" sound/foo.mp3" );
34+ constexpr VFS::Path::NormalizedView wavPath (" sound/foo.wav" );
35+ constexpr VFS::Path::NormalizedView mp3Path (" sound/foo.mp3" );
3036 const std::unique_ptr<const VFS::Manager> vfs = TestingOpenMW::createTestVFS ({
31- { wav , nullptr },
32- { mp3 , nullptr },
37+ { wavPath , nullptr },
38+ { mp3Path , nullptr },
3339 });
34- EXPECT_EQ (correctSoundPath (wav , *vfs), " sound/foo.wav" );
40+ EXPECT_EQ (correctSoundPath (wavPath , *vfs), " sound/foo.wav" );
3541 }
3642
37- TEST (MiscResourceHelpersCorrectResourcePath, shouldFallbackToGivenExtentionIfDoesNotExistInVfs )
43+ TEST (MiscResourceHelpersCorrectResourcePath, shouldFallbackToGivenExtensionIfDoesNotExistInVfs )
3844 {
45+ constexpr VFS::Path::NormalizedView path (" sound/foo.wav" );
3946 const std::unique_ptr<const VFS::Manager> vfs = TestingOpenMW::createTestVFS ({});
40- EXPECT_EQ (correctResourcePath ({ { " sound" } }, " sound/foo.wav " , vfs. get (), " mp3" ), " sound/foo.mp3" );
47+ EXPECT_EQ (correctResourcePath ({ { sound } }, path, * vfs, mp3), " sound/foo.mp3" );
4148 }
4249
43- TEST (MiscResourceHelpersCorrectResourcePath, shouldFallbackToGivenExtentionIfBothExistInVfs )
50+ TEST (MiscResourceHelpersCorrectResourcePath, shouldFallbackToGivenExtensionIfBothExistInVfs )
4451 {
45- constexpr VFS::Path::NormalizedView wav (" sound/foo.wav" );
46- constexpr VFS::Path::NormalizedView mp3 (" sound/foo.mp3" );
52+ constexpr VFS::Path::NormalizedView wavPath (" sound/foo.wav" );
53+ constexpr VFS::Path::NormalizedView mp3Path (" sound/foo.mp3" );
4754 const std::unique_ptr<const VFS::Manager> vfs = TestingOpenMW::createTestVFS ({
48- { wav , nullptr },
49- { mp3 , nullptr },
55+ { wavPath , nullptr },
56+ { mp3Path , nullptr },
5057 });
51- EXPECT_EQ (correctResourcePath ({ { " sound" } }, wav. value (), vfs. get (), " mp3" ), " sound/foo.mp3" );
58+ EXPECT_EQ (correctResourcePath ({ { sound } }, wavPath, * vfs, mp3), " sound/foo.mp3" );
5259 }
5360
54- TEST (MiscResourceHelpersCorrectResourcePath, shouldKeepExtentionIfExistInVfs )
61+ TEST (MiscResourceHelpersCorrectResourcePath, shouldKeepExtensionIfExistInVfs )
5562 {
56- constexpr VFS::Path::NormalizedView wav (" sound/foo.wav" );
63+ constexpr VFS::Path::NormalizedView wavPath (" sound/foo.wav" );
5764 const std::unique_ptr<const VFS::Manager> vfs = TestingOpenMW::createTestVFS ({
58- { wav , nullptr },
65+ { wavPath , nullptr },
5966 });
60- EXPECT_EQ (correctResourcePath ({ { " sound" } }, wav. value (), vfs. get (), " mp3" ), " sound/foo.wav" );
67+ EXPECT_EQ (correctResourcePath ({ { sound } }, wavPath, * vfs, mp3), " sound/foo.wav" );
6168 }
6269
6370 TEST (MiscResourceHelpersCorrectResourcePath, shouldPrefixWithGivenTopDirectory)
6471 {
72+ constexpr VFS::Path::NormalizedView path (" foo.mp3" );
6573 const std::unique_ptr<const VFS::Manager> vfs = TestingOpenMW::createTestVFS ({});
66- EXPECT_EQ (correctResourcePath ({ { " sound" } }, " foo.mp3 " , vfs. get (), " mp3" ), " sound/foo.mp3" );
74+ EXPECT_EQ (correctResourcePath ({ { sound } }, path, * vfs, mp3), " sound/foo.mp3" );
6775 }
6876
6977 TEST (MiscResourceHelpersCorrectResourcePath, shouldChangeTopDirectoryAndKeepExtensionIfOriginalExistInVfs)
7078 {
71- constexpr VFS::Path::NormalizedView a (" textures/foo.a" );
79+ constexpr VFS::Path::NormalizedView path (" bookart/foo.a" );
80+ constexpr VFS::Path::NormalizedView aPath (" textures/foo.a" );
7281 const std::unique_ptr<const VFS::Manager> vfs = TestingOpenMW::createTestVFS ({
73- { a , nullptr },
82+ { aPath , nullptr },
7483 });
75- EXPECT_EQ (
76- correctResourcePath ({ { " textures" , " bookart" } }, " bookart/foo.a" , vfs.get (), " b" ), " textures/foo.a" );
84+ EXPECT_EQ (correctResourcePath ({ { textures, bookart } }, path, *vfs, b), " textures/foo.a" );
7785 }
7886
7987 TEST (MiscResourceHelpersCorrectResourcePath, shouldChangeTopDirectoryAndChangeExtensionIfFallbackExistInVfs)
8088 {
81- constexpr VFS::Path::NormalizedView b (" textures/foo.b" );
89+ constexpr VFS::Path::NormalizedView path (" bookart/foo.a" );
90+ constexpr VFS::Path::NormalizedView bPath (" textures/foo.b" );
8291 const std::unique_ptr<const VFS::Manager> vfs = TestingOpenMW::createTestVFS ({
83- { b , nullptr },
92+ { bPath , nullptr },
8493 });
85- EXPECT_EQ (
86- correctResourcePath ({ { " textures" , " bookart" } }, " bookart/foo.a" , vfs.get (), " b" ), " textures/foo.b" );
87- }
88-
89- TEST (MiscResourceHelpersCorrectResourcePath, shouldLowerCase)
90- {
91- const std::unique_ptr<const VFS::Manager> vfs = TestingOpenMW::createTestVFS ({});
92- EXPECT_EQ (correctResourcePath ({ { " sound" } }, " SOUND\\ Foo.MP3" , vfs.get (), " mp3" ), " sound/foo.mp3" );
93- }
94-
95- TEST (MiscResourceHelpersCorrectResourcePath, shouldRemoveLeadingSlash)
96- {
97- const std::unique_ptr<const VFS::Manager> vfs = TestingOpenMW::createTestVFS ({});
98- EXPECT_EQ (correctResourcePath ({ { " sound" } }, " \\ SOUND\\ Foo.MP3" , vfs.get (), " mp3" ), " sound/foo.mp3" );
99- }
100-
101- TEST (MiscResourceHelpersCorrectResourcePath, shouldRemoveDuplicateSlashes)
102- {
103- const std::unique_ptr<const VFS::Manager> vfs = TestingOpenMW::createTestVFS ({});
104- EXPECT_EQ (correctResourcePath ({ { " sound" } }, " \\\\ SOUND\\\\ Foo.MP3" , vfs.get (), " mp3" ), " sound/foo.mp3" );
105- }
106-
107- TEST (MiscResourceHelpersCorrectResourcePath, shouldConvertToForwardSlash)
108- {
109- const std::unique_ptr<const VFS::Manager> vfs = TestingOpenMW::createTestVFS ({});
110- EXPECT_EQ (correctResourcePath ({ { " sound" } }, " SOUND/Foo.MP3" , vfs.get (), " mp3" ), " sound/foo.mp3" );
94+ EXPECT_EQ (correctResourcePath ({ { textures, bookart } }, path, *vfs, b), " textures/foo.b" );
11195 }
11296
11397 TEST (MiscResourceHelpersCorrectResourcePath, shouldHandlePathEqualToDirectory)
11498 {
99+ constexpr VFS::Path::NormalizedView path (" sound" );
115100 const std::unique_ptr<const VFS::Manager> vfs = TestingOpenMW::createTestVFS ({});
116- EXPECT_EQ (correctResourcePath ({ { " sound" } }, " sound " , vfs. get (), " mp3" ), " sound/sound" );
101+ EXPECT_EQ (correctResourcePath ({ { sound } }, path, * vfs, mp3), " sound/sound" );
117102 }
118103
119- struct MiscResourceHelpersCorrectResourcePathShouldRemoveExtraPrefix : TestWithParam<std::string >
104+ struct MiscResourceHelpersCorrectResourcePathShouldRemoveExtraPrefix : TestWithParam<VFS::Path::NormalizedView >
120105 {
121106 };
122107
123108 TEST_P (MiscResourceHelpersCorrectResourcePathShouldRemoveExtraPrefix, shouldMatchExpected)
124109 {
125110 const std::unique_ptr<const VFS::Manager> vfs = TestingOpenMW::createTestVFS ({});
126- EXPECT_EQ (correctResourcePath ({ { " sound" } }, GetParam (), vfs. get (), " mp3" ), " sound/foo.mp3" );
111+ EXPECT_EQ (correctResourcePath ({ { sound } }, GetParam (), * vfs, mp3), " sound/foo.mp3" );
127112 }
128113
129- const std::vector<std::string > pathsWithPrefix = {
130- " data/sound/foo.mp3" ,
131- " data/notsound/sound/foo.mp3" ,
132- " data/soundnot/sound/foo.mp3" ,
133- " data/notsoundnot/sound/foo.mp3" ,
114+ const std::vector<VFS::Path::NormalizedView > pathsWithPrefix = {
115+ VFS::Path::NormalizedView ( " data/sound/foo.mp3" ) ,
116+ VFS::Path::NormalizedView ( " data/notsound/sound/foo.mp3" ) ,
117+ VFS::Path::NormalizedView ( " data/soundnot/sound/foo.mp3" ) ,
118+ VFS::Path::NormalizedView ( " data/notsoundnot/sound/foo.mp3" ) ,
134119 };
135120
136121 INSTANTIATE_TEST_SUITE_P (
0 commit comments