1#include <gtest/gtest.h>
2
3#include <base/system.h>
4#include <engine/storage.h>
5
6class StripPathAndExtension : public ::testing::Test
7{
8protected:
9 void Test(const char *pInput, const char *pOutput)
10 {
11 char aBuf[32];
12 IStorage::StripPathAndExtension(pFilename: pInput, pBuffer: aBuf, BufferSize: sizeof(aBuf));
13 EXPECT_STREQ(aBuf, pOutput);
14 }
15};
16
17TEST_F(StripPathAndExtension, WorksOnBareFilename)
18{
19 Test(pInput: "abc", pOutput: "abc");
20}
21
22TEST_F(StripPathAndExtension, NormalPath)
23{
24 Test(pInput: "/usr/share/teeworlds/data/mapres/grass_main.png", pOutput: "grass_main");
25}
26
27TEST_F(StripPathAndExtension, NormalFile)
28{
29 Test(pInput: "winter_main.png", pOutput: "winter_main");
30}
31
32TEST_F(StripPathAndExtension, DotInFolder)
33{
34 Test(pInput: "C:\\a.b\\c", pOutput: "c");
35}
36
37TEST_F(StripPathAndExtension, DoubleDot)
38{
39 Test(pInput: "file.name.png", pOutput: "file.name");
40}
41