- Create
testdirectory - Create
gtest_main.cppintotest - Create test class files into
test - Create
Makefileintotestand connect each test class togtest_main
Now, you can check build status on https://travis-ci.com/.
| language: cpp | |
| sudo: false | |
| matrix: | |
| include: | |
| # works on Precise and Trusty | |
| - os: linux | |
| addons: | |
| apt: | |
| sources: | |
| - ubuntu-toolchain-r-test | |
| - george-edison55-precise-backports | |
| packages: | |
| - g++-5 | |
| - cmake | |
| - libgtest-dev | |
| env: | |
| - MATRIX_EVAL="CC=gcc-5 && CXX=g++-5" | |
| # works on Precise and Trusty | |
| - os: linux | |
| addons: | |
| apt: | |
| sources: | |
| - ubuntu-toolchain-r-test | |
| - george-edison55-precise-backports | |
| packages: | |
| - g++-6 | |
| - cmake | |
| - libgtest-dev | |
| env: | |
| - MATRIX_EVAL="CC=gcc-6 && CXX=g++-6" | |
| # works on Precise and Trusty | |
| - os: linux | |
| addons: | |
| apt: | |
| sources: | |
| - ubuntu-toolchain-r-test | |
| - george-edison55-precise-backports | |
| packages: | |
| - g++-7 | |
| - cmake | |
| - libgtest-dev | |
| env: | |
| - MATRIX_EVAL="CC=gcc-7 && CXX=g++-7" | |
| before_install : | |
| - eval "${MATRIX_EVAL}" | |
| - git submodule update --init --recursive | |
| install: | |
| - cd /usr/src/gtest && sudo cmake . && sudo cmake --build . && sudo mv libg* /usr/local/lib/ ; cd - | |
| script: | |
| - g++ --version | |
| - cd {path/to/your/test_dir} | |
| - make && ./gtest_main | |
| - cd ../.. | |
| git: | |
| submodule: false |
| /* | |
| * This is Example of Test Class | |
| */ | |
| #include <gtest/gtest.h> | |
| #include "../Block.h" | |
| #include "Eigen/Core" | |
| class BlockTest : public ::testing::Test{ | |
| protected: | |
| std::vector<Block> blocks; | |
| BlockTest(){ | |
| blocks.emplace_back(Eigen::Vector2d(0.0,0.0), 20.0); | |
| blocks.emplace_back(Eigen::Vector2d(10.0,0.0), 30.0); | |
| blocks.emplace_back(Eigen::Vector2d(0.0,100.0), 100.0); | |
| } | |
| }; | |
| TEST_F(BlockTest, size) | |
| { | |
| EXPECT_EQ(20.0, blocks[0].size); | |
| EXPECT_EQ(30.0, blocks[1].size); | |
| EXPECT_EQ(100.0, blocks[2].size); | |
| } | |
| TEST_F(BlockTest, pos) | |
| { | |
| EXPECT_EQ(Eigen::Vector2d(0.0,0.0), blocks[0].pos); | |
| EXPECT_EQ(Eigen::Vector2d(10.0,0.0), blocks[1].pos); | |
| EXPECT_EQ(Eigen::Vector2d(0.0,100.0), blocks[2].pos); | |
| } | |
| //TODO: add propagation test and back propagation test here |
| #include <gtest/gtest.h> | |
| int main(int argc, char **argv) { | |
| ::testing::InitGoogleTest(&argc, argv); | |
| return RUN_ALL_TESTS(); | |
| } |
| CC = g++-7 | |
| CFLAGS = -std=gnu++1z -I {Include Files} -Wall -Wextra -pedantic | |
| SOURCES = {Your source files} | |
| TESTS = {Your test files} | |
| gtest_main: gtest_main.cpp | |
| $(CC) $(CFLAGS) -o gtest_main gtest_main.cpp ${SOURCES} ${TESTS} -lgtest -lgtest_main -pthread |
test directorygtest_main.cpp into testtestMakefile into test and connect each test class to gtest_mainNow, you can check build status on https://travis-ci.com/.