mirror of https://github.com/OpenMW/openmw
Fix NormalizedView::stem to include dots
This commit is contained in:
parent
d5c7a6c6db
commit
2d33ead98d
|
|
@ -338,5 +338,23 @@ namespace VFS::Path
|
|||
const NormalizedView value("foo");
|
||||
EXPECT_EQ(value.filename(), "foo");
|
||||
}
|
||||
|
||||
TEST(VFSPathNormalizedViewTest, stemShouldOmitPathAndExtension)
|
||||
{
|
||||
const NormalizedView value("foo/bar.a");
|
||||
EXPECT_EQ(value.stem(), "bar");
|
||||
}
|
||||
|
||||
TEST(VFSPathNormalizedViewTest, stemShouldReturnSameValueForPathWithSingleComponent)
|
||||
{
|
||||
const NormalizedView value("foo");
|
||||
EXPECT_EQ(value.stem(), "foo");
|
||||
}
|
||||
|
||||
TEST(VFSPathNormalizedViewTest, stemShouldIncludeDotsBeforeTheExtension)
|
||||
{
|
||||
const NormalizedView value("last voyage of the u.s.s. constitution.swf");
|
||||
EXPECT_EQ(value.stem(), "last voyage of the u.s.s. constitution");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -232,18 +232,6 @@ namespace VFS::Path
|
|||
return p;
|
||||
}
|
||||
|
||||
std::string_view stem() const
|
||||
{
|
||||
std::string_view stem = mValue;
|
||||
std::size_t pos = stem.find_last_of(separator);
|
||||
if (pos != std::string_view::npos)
|
||||
stem = stem.substr(pos + 1);
|
||||
pos = stem.find_first_of(extensionSeparator);
|
||||
if (pos != std::string_view::npos)
|
||||
stem = stem.substr(0, pos);
|
||||
return stem;
|
||||
}
|
||||
|
||||
NormalizedView filename() const
|
||||
{
|
||||
NormalizedView result(*this);
|
||||
|
|
@ -252,6 +240,14 @@ namespace VFS::Path
|
|||
return result;
|
||||
}
|
||||
|
||||
std::string_view stem() const
|
||||
{
|
||||
std::string_view stem = filename().value();
|
||||
if (const std::size_t pos = stem.find_last_of(extensionSeparator); pos != std::string_view::npos)
|
||||
stem = stem.substr(0, pos);
|
||||
return stem;
|
||||
}
|
||||
|
||||
constexpr ExtensionView extension() const
|
||||
{
|
||||
ExtensionView result;
|
||||
|
|
|
|||
Loading…
Reference in New Issue