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