Skip to content

Commit

Permalink
[test] add unit test for URIUtils::UpdateUrlEncoding
Browse files Browse the repository at this point in the history
  • Loading branch information
Montellese committed Oct 31, 2012
1 parent 9c0fc99 commit cbfaa76
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions xbmc/utils/test/TestURIUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}

0 comments on commit cbfaa76

Please sign in to comment.