[test] add unit test for URIUtils::UpdateUrlEncoding
authormontellese <montellese@xbmc.org>
Tue, 30 Oct 2012 13:56:38 +0000 (14:56 +0100)
committermontellese <montellese@xbmc.org>
Wed, 31 Oct 2012 08:11:01 +0000 (09:11 +0100)
xbmc/utils/test/TestURIUtils.cpp

index 7634b48..4cf02e9 100644 (file)
@@ -550,3 +550,30 @@ TEST_F(TestURIUtils, GetRealPath)
   ref ="zip://rar%3A%2F%2F%252Fpath%252Fto%252Frar%2Fpath%2Fto%2Fzip/subpath/to/file";
   EXPECT_STRCASEEQ(ref.c_str(), URIUtils::GetRealPath("zip://rar%3A%2F%2F%252Fpath%252Fto%252Fsome%252F..%252Frar%2Fpath%2Fto%2Fsome%2F..%2Fzip/subpath/to/some/../file").c_str());
 }
+
+TEST_F(TestURIUtils, UpdateUrlEncoding)
+{
+  std::string oldUrl = "stack://rar://%2fpath%2fto%2farchive%2fsome%2darchive%2dfile%2eCD1%2erar/video.avi , rar://%2fpath%2fto%2farchive%2fsome%2darchive%2dfile%2eCD2%2erar/video.avi";
+  std::string newUrl = "stack://rar://%2fpath%2fto%2farchive%2fsome-archive-file.CD1.rar/video.avi , rar://%2fpath%2fto%2farchive%2fsome-archive-file.CD2.rar/video.avi";
+
+  EXPECT_TRUE(URIUtils::UpdateUrlEncoding(oldUrl));
+  EXPECT_STRCASEEQ(newUrl.c_str(), oldUrl.c_str());
+
+  oldUrl = "rar://%2fpath%2fto%2farchive%2fsome%2darchive%2efile%2erar/video.avi";
+  newUrl = "rar://%2fpath%2fto%2farchive%2fsome-archive.file.rar/video.avi";
+  
+  EXPECT_TRUE(URIUtils::UpdateUrlEncoding(oldUrl));
+  EXPECT_STRCASEEQ(newUrl.c_str(), oldUrl.c_str());
+  
+  oldUrl = "/path/to/some/long%2dnamed%2efile";
+  newUrl = "/path/to/some/long%2dnamed%2efile";
+  
+  EXPECT_FALSE(URIUtils::UpdateUrlEncoding(oldUrl));
+  EXPECT_STRCASEEQ(newUrl.c_str(), oldUrl.c_str());
+  
+  oldUrl = "/path/to/some/long-named.file";
+  newUrl = "/path/to/some/long-named.file";
+  
+  EXPECT_FALSE(URIUtils::UpdateUrlEncoding(oldUrl));
+  EXPECT_STRCASEEQ(newUrl.c_str(), oldUrl.c_str());
+}