ddnet/src/test/strip_path_and_extension.cpp

41 lines
759 B
C++
Raw Normal View History

#include <gtest/gtest.h>
#include <base/system.h>
#include <engine/storage.h>
2017-08-30 20:18:48 +00:00
class StripPathAndExtension : public ::testing::Test
{
protected:
void Test(const char *pInput, const char *pOutput)
2017-08-30 20:18:48 +00:00
{
char aBuf[32];
IStorage::StripPathAndExtension(pInput, aBuf, sizeof(aBuf));
EXPECT_STREQ(aBuf, pOutput);
}
2017-08-30 20:18:48 +00:00
};
TEST_F(StripPathAndExtension, WorksOnBareFilename)
{
Test("abc", "abc");
2017-08-30 20:18:48 +00:00
}
TEST_F(StripPathAndExtension, NormalPath)
{
Test("/usr/share/teeworlds/data/mapres/grass_main.png", "grass_main");
2017-08-30 20:18:48 +00:00
}
TEST_F(StripPathAndExtension, NormalFile)
{
Test("winter_main.png", "winter_main");
2017-08-30 20:18:48 +00:00
}
TEST_F(StripPathAndExtension, DotInFolder)
{
Test("C:\\a.b\\c", "c");
2017-08-30 20:18:48 +00:00
}
TEST_F(StripPathAndExtension, DoubleDot)
{
Test("file.name.png", "file.name");
2017-08-30 20:18:48 +00:00
}