1 | #include <gtest/gtest.h> |
2 | |
3 | #include <base/system.h> |
4 | #include <engine/storage.h> |
5 | |
6 | class StripPathAndExtension : public ::testing::Test |
7 | { |
8 | protected: |
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 | |
17 | TEST_F(StripPathAndExtension, WorksOnBareFilename) |
18 | { |
19 | Test(pInput: "abc" , pOutput: "abc" ); |
20 | } |
21 | |
22 | TEST_F(StripPathAndExtension, NormalPath) |
23 | { |
24 | Test(pInput: "/usr/share/teeworlds/data/mapres/grass_main.png" , pOutput: "grass_main" ); |
25 | } |
26 | |
27 | TEST_F(StripPathAndExtension, NormalFile) |
28 | { |
29 | Test(pInput: "winter_main.png" , pOutput: "winter_main" ); |
30 | } |
31 | |
32 | TEST_F(StripPathAndExtension, DotInFolder) |
33 | { |
34 | Test(pInput: "C:\\a.b\\c" , pOutput: "c" ); |
35 | } |
36 | |
37 | TEST_F(StripPathAndExtension, DoubleDot) |
38 | { |
39 | Test(pInput: "file.name.png" , pOutput: "file.name" ); |
40 | } |
41 | |