Skip to content

Commit

Permalink
#5568: Add some unit test for the newly added os::removeExtension fun…
Browse files Browse the repository at this point in the history
…ction, as well as for the existing os::getExtension.
  • Loading branch information
codereader committed Mar 23, 2021
1 parent 5c58e0f commit eba0c55
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions test/Basic.cpp
Expand Up @@ -6,6 +6,7 @@
#include "gtest/gtest.h"

#include "string/string.h"
#include "os/path.h"

namespace test
{
Expand All @@ -32,4 +33,33 @@ TEST(BasicTest, StringILessFunctor)
EXPECT_TRUE(!less("BLEH", "blah"));
}

TEST(PathTests, GetFileExtension)
{
EXPECT_EQ(os::getExtension(""), "");
EXPECT_EQ(os::getExtension("file55"), "");
EXPECT_EQ(os::getExtension("file55."), "");
EXPECT_EQ(os::getExtension("file.extension"), "extension");
EXPECT_EQ(os::getExtension("File.TGA"), "TGA");
EXPECT_EQ(os::getExtension("File.tga"), "tga");
EXPECT_EQ(os::getExtension("file.tga.bak"), "bak");
EXPECT_EQ(os::getExtension("relativefolder/file.tga"), "tga");
EXPECT_EQ(os::getExtension("c:\\absolutepath\\tork.bak"), "bak");
EXPECT_EQ(os::getExtension("\\absolutepath\\tork.doc"), "doc");
EXPECT_EQ(os::getExtension("dds/textures/darkmod/test.dds"), "dds");
}

TEST(PathTests, RemoveFileExtension)
{
EXPECT_EQ(os::removeExtension(""), "");
EXPECT_EQ(os::removeExtension("file55"), "file55");
EXPECT_EQ(os::removeExtension("file55."), "file55");
EXPECT_EQ(os::removeExtension("file.extension"), "file");
EXPECT_EQ(os::removeExtension("File.tga"), "File");
EXPECT_EQ(os::removeExtension("file.tga.bak"), "file.tga");
EXPECT_EQ(os::removeExtension("relativefolder/file.tga"), "relativefolder/file");
EXPECT_EQ(os::removeExtension("c:\\absolutepath\\tork.bak"), "c:\\absolutepath\\tork");
EXPECT_EQ(os::removeExtension("\\absolutepath\\tork.doc"), "\\absolutepath\\tork");
EXPECT_EQ(os::removeExtension("dds/textures/darkmod/test.dds"), "dds/textures/darkmod/test");
}

}

0 comments on commit eba0c55

Please sign in to comment.