2017-08-30 19:57:55 +00:00
|
|
|
#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:
|
2017-08-30 23:39:08 +00:00
|
|
|
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));
|
2017-09-28 00:03:30 +00:00
|
|
|
EXPECT_STREQ(aBuf, pOutput);
|
2017-08-30 19:57:55 +00:00
|
|
|
}
|
2017-08-30 20:18:48 +00:00
|
|
|
};
|
2017-08-30 19:57:55 +00:00
|
|
|
|
2017-08-30 23:39:08 +00:00
|
|
|
TEST_F(StripPathAndExtension, WorksOnBareFilename)
|
|
|
|
{
|
|
|
|
Test("abc", "abc");
|
2017-08-30 20:18:48 +00:00
|
|
|
}
|
|
|
|
|
2017-08-30 23:39:08 +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
|
|
|
}
|
|
|
|
|
2017-08-30 23:39:08 +00:00
|
|
|
TEST_F(StripPathAndExtension, NormalFile)
|
|
|
|
{
|
|
|
|
Test("winter_main.png", "winter_main");
|
2017-08-30 20:18:48 +00:00
|
|
|
}
|
|
|
|
|
2017-08-30 23:39:08 +00:00
|
|
|
TEST_F(StripPathAndExtension, DotInFolder)
|
|
|
|
{
|
|
|
|
Test("C:\\a.b\\c", "c");
|
2017-08-30 20:18:48 +00:00
|
|
|
}
|
|
|
|
|
2017-08-30 23:39:08 +00:00
|
|
|
TEST_F(StripPathAndExtension, DoubleDot)
|
|
|
|
{
|
|
|
|
Test("file.name.png", "file.name");
|
2017-08-30 20:18:48 +00:00
|
|
|
}
|