fix Path::ext() when new_ext == ""
This commit is contained in:
parent
a1e9c30af2
commit
cae4b077d9
@ -58,7 +58,11 @@ namespace jes
|
|||||||
}
|
}
|
||||||
i--;
|
i--;
|
||||||
}
|
}
|
||||||
if (new_ext[0] == '.')
|
if (new_ext.size() == 0)
|
||||||
|
{
|
||||||
|
return new Path(std::string(m_path, 0, i));
|
||||||
|
}
|
||||||
|
else if (new_ext[0] == '.')
|
||||||
{
|
{
|
||||||
return new Path(std::string(m_path, 0, i) + new_ext);
|
return new Path(std::string(m_path, 0, i) + new_ext);
|
||||||
}
|
}
|
||||||
|
@ -49,6 +49,7 @@ TEST(PathTest, ext)
|
|||||||
EXPECT_EQ("file.h", Path("file.c").ext("h")->to_s());
|
EXPECT_EQ("file.h", Path("file.c").ext("h")->to_s());
|
||||||
EXPECT_EQ("/some/crazy/dir/foo.txt", Path("/some/crazy/dir/foo").ext(".txt")->to_s());
|
EXPECT_EQ("/some/crazy/dir/foo.txt", Path("/some/crazy/dir/foo").ext(".txt")->to_s());
|
||||||
EXPECT_EQ("/some/crazy/dir/foo.txt", Path("/some/crazy/dir/foo").ext("txt")->to_s());
|
EXPECT_EQ("/some/crazy/dir/foo.txt", Path("/some/crazy/dir/foo").ext("txt")->to_s());
|
||||||
|
EXPECT_EQ("C:/baz", Path("C:\\baz.xyz").ext("")->to_s());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(PathTest, exists)
|
TEST(PathTest, exists)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user