Run tests on Travis on Linux

Fix the style of our only test.
This commit is contained in:
heinrich5991 2017-08-31 01:39:08 +02:00
parent a20db6ec56
commit fc44bfcc76
2 changed files with 21 additions and 12 deletions

View file

@ -8,13 +8,17 @@ addons:
apt: apt:
packages: packages:
- libfreetype6-dev - libfreetype6-dev
- libgtest-dev
- libsdl2-dev - libsdl2-dev
script: script:
- if [ "$TRAVIS_OS_NAME" = "osx" ]; then brew install sdl2; fi - if [ "$TRAVIS_OS_NAME" = "osx" ]; then brew install sdl2; fi
- if [ "$TRAVIS_OS_NAME" != "osx" ]; then mkdir gtest_build; cmake -E chdir gtest_build cmake /usr/src/gtest; cmake --build gtest_build; fi
- mkdir build - mkdir build
- cd build - cd build
- cmake -Werror=dev .. - if [ "$TRAVIS_OS_NAME" = "osx" ]; then cmake -Werror=dev ..; fi
- if [ "$TRAVIS_OS_NAME" != "osx" ]; then cmake -Werror=dev -DGTEST_LIBRARY=../gtest_build/libgtest.a -DGTEST_MAIN_LIBRARY=../gtest_build/libgtest_main.a ..; fi
- make everything - make everything
- if [ "$TRAVIS_OS_NAME" != "osx" ]; then make run_tests; fi
env: env:
global: global:
- CFLAGS="-Wdeclaration-after-statement -Werror" - CFLAGS="-Wdeclaration-after-statement -Werror"

View file

@ -6,7 +6,7 @@
class StripPathAndExtension : public ::testing::Test class StripPathAndExtension : public ::testing::Test
{ {
protected: protected:
void testEq(const char *pInput, const char *pOutput) void Test(const char *pInput, const char *pOutput)
{ {
char aBuf[32]; char aBuf[32];
IStorage::StripPathAndExtension(pInput, aBuf, sizeof(aBuf)); IStorage::StripPathAndExtension(pInput, aBuf, sizeof(aBuf));
@ -14,22 +14,27 @@ protected:
} }
}; };
TEST_F(StripPathAndExtension, WorksOnBareFilename) { TEST_F(StripPathAndExtension, WorksOnBareFilename)
testEq("abc", "abc"); {
Test("abc", "abc");
} }
TEST_F(StripPathAndExtension, NormalPath) { TEST_F(StripPathAndExtension, NormalPath)
testEq("/usr/share/teeworlds/data/mapres/grass_main.png", "grass_main"); {
Test("/usr/share/teeworlds/data/mapres/grass_main.png", "grass_main");
} }
TEST_F(StripPathAndExtension, NormalFile) { TEST_F(StripPathAndExtension, NormalFile)
testEq("winter_main.png", "winter_main"); {
Test("winter_main.png", "winter_main");
} }
TEST_F(StripPathAndExtension, DotInFolder) { TEST_F(StripPathAndExtension, DotInFolder)
testEq("C:\\a.b\\c", "c"); {
Test("C:\\a.b\\c", "c");
} }
TEST_F(StripPathAndExtension, DoubleDot) { TEST_F(StripPathAndExtension, DoubleDot)
testEq("file.name.png", "file.name"); {
Test("file.name.png", "file.name");
} }