From cae4b077d9b912441ab33a19b089760b7726aefb Mon Sep 17 00:00:00 2001 From: Josh Holtrop Date: Sun, 22 Jun 2014 21:01:38 -0400 Subject: [PATCH] fix Path::ext() when new_ext == "" --- src/lib/src/Path.cc | 6 +++++- test/src/test_Path.cc | 1 + 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/lib/src/Path.cc b/src/lib/src/Path.cc index 32c62b1..970f116 100644 --- a/src/lib/src/Path.cc +++ b/src/lib/src/Path.cc @@ -58,7 +58,11 @@ namespace jes } 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); } diff --git a/test/src/test_Path.cc b/test/src/test_Path.cc index fcc7752..9cff6ea 100644 --- a/test/src/test_Path.cc +++ b/test/src/test_Path.cc @@ -49,6 +49,7 @@ TEST(PathTest, ext) 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("C:/baz", Path("C:\\baz.xyz").ext("")->to_s()); } TEST(PathTest, exists)