aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorarnova <arnova@void.org>2013-11-09 15:01:51 +0100
committerarnova <arnova@void.org>2014-01-05 09:41:30 +0100
commit217b46b10f68eded1a982a946a96b7e37eeda577 (patch)
tree0e818033dd4423af848870643e74bc4d0731e709
parent56e0a42dc4c538137032ca5f54fbfd3f8ed809db (diff)
changed: Extend path substitude unit test
-rw-r--r--xbmc/utils/test/TestURIUtils.cpp52
1 files changed, 48 insertions, 4 deletions
diff --git a/xbmc/utils/test/TestURIUtils.cpp b/xbmc/utils/test/TestURIUtils.cpp
index 7170c46939..9af7f2fc27 100644
--- a/xbmc/utils/test/TestURIUtils.cpp
+++ b/xbmc/utils/test/TestURIUtils.cpp
@@ -178,12 +178,56 @@ TEST_F(TestURIUtils, SubstitutePath)
{
CStdString from, to, ref, var;
- from = "/somepath";
- to = "/someotherpath";
+ from = "C:\\My Videos";
+ to = "https://myserver/some%20other%20path";
g_advancedSettings.m_pathSubstitutions.push_back(std::make_pair(from, to));
- ref = "/someotherpath/to/movie.avi";
- var = URIUtils::SubstitutePath("/somepath/to/movie.avi");
+ from = "/this/path1";
+ to = "/some/other/path2";
+ g_advancedSettings.m_pathSubstitutions.push_back(std::make_pair(from, to));
+
+ from = "davs://otherserver/my%20music%20path";
+ to = "D:\\Local Music\\MP3 Collection";
+ g_advancedSettings.m_pathSubstitutions.push_back(std::make_pair(from, to));
+
+ ref = "https://myserver/some%20other%20path/sub%20dir/movie%20name.avi";
+ var = URIUtils::SubstitutePath("C:\\My Videos\\sub dir\\movie name.avi");
+ EXPECT_STREQ(ref.c_str(), var.c_str());
+
+ ref = "C:\\My Videos\\sub dir\\movie name.avi";
+ var = URIUtils::SubstitutePath("https://myserver/some%20other%20path/sub%20dir/movie%20name.avi", true);
+ EXPECT_STREQ(ref.c_str(), var.c_str());
+
+ ref = "D:\\Local Music\\MP3 Collection\\Phil Collins\\Some CD\\01 - Two Hearts.mp3";
+ var = URIUtils::SubstitutePath("davs://otherserver/my%20music%20path/Phil%20Collins/Some%20CD/01%20-%20Two%20Hearts.mp3");
+ EXPECT_STREQ(ref.c_str(), var.c_str());
+
+ ref = "davs://otherserver/my%20music%20path/Phil%20Collins/Some%20CD/01%20-%20Two%20Hearts.mp3";
+ var = URIUtils::SubstitutePath("D:\\Local Music\\MP3 Collection\\Phil Collins\\Some CD\\01 - Two Hearts.mp3", true);
+ EXPECT_STREQ(ref.c_str(), var.c_str());
+
+ ref = "/some/other/path2/to/movie.avi";
+ var = URIUtils::SubstitutePath("/this/path1/to/movie.avi");
+ EXPECT_STREQ(ref.c_str(), var.c_str());
+
+ ref = "/this/path1/to/movie.avi";
+ var = URIUtils::SubstitutePath("/some/other/path2/to/movie.avi", true);
+ EXPECT_STREQ(ref.c_str(), var.c_str());
+
+ ref = "/no/translation path/";
+ var = URIUtils::SubstitutePath(ref);
+ EXPECT_STREQ(ref.c_str(), var.c_str());
+
+ ref = "/no/translation path/";
+ var = URIUtils::SubstitutePath(ref, true);
+ EXPECT_STREQ(ref.c_str(), var.c_str());
+
+ ref = "c:\\no\\translation path";
+ var = URIUtils::SubstitutePath(ref);
+ EXPECT_STREQ(ref.c_str(), var.c_str());
+
+ ref = "c:\\no\\translation path";
+ var = URIUtils::SubstitutePath(ref, true);
EXPECT_STREQ(ref.c_str(), var.c_str());
}