Skip to content

Commit c08dec4

Browse files
committed
[GUnit] init
0 parents  commit c08dec4

File tree

21 files changed

+3162
-0
lines changed

21 files changed

+3162
-0
lines changed

.clang-format

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
Language: Cpp
3+
Standard: Cpp11
4+
BasedOnStyle: Google
5+
ColumnLimit: 128
6+
---

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[submodule "libs/googletest"]
2+
path = libs/googletest
3+
url = https://github.com/google/googletest.git

.travis.yml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
#
2+
# Copyright (c) 2016-2017 Kris Jusiak (kris at jusiak dot net)
3+
#
4+
# Distributed under the Boost Software License, Version 1.0.
5+
# (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6+
#
7+
sudo: false
8+
9+
matrix:
10+
fast_finish: true
11+
12+
include:
13+
- os: linux
14+
env: CXX=clang++-3.6
15+
addons:
16+
apt:
17+
packages: ["clang-3.6", "libstdc++-5-dev", "valgrind"]
18+
sources: ["ubuntu-toolchain-r-test", "llvm-toolchain-precise-3.6"]
19+
- os: linux
20+
env: CXX=clang++-3.7
21+
addons:
22+
apt:
23+
packages: ["clang-3.7", "libstdc++-5-dev", "valgrind"]
24+
sources: ["ubuntu-toolchain-r-test", "llvm-toolchain-precise-3.7"]
25+
- os: linux
26+
env: CXX=clang++-3.8
27+
addons:
28+
apt:
29+
packages: ["clang-3.8", "libstdc++-5-dev", "valgrind"]
30+
sources: ["ubuntu-toolchain-r-test", "llvm-toolchain-precise-3.8"]
31+
- os: linux
32+
env: CXX=g++-5
33+
addons:
34+
apt:
35+
packages: ["g++-5", "libstdc++-5-dev", "valgrind"]
36+
sources: ["ubuntu-toolchain-r-test"]
37+
- os: linux
38+
env: CXX=g++-6
39+
addons:
40+
apt:
41+
packages: ["g++-6", "libstdc++-6-dev", "valgrind"]
42+
sources: ["ubuntu-toolchain-r-test"]
43+
- os: osx
44+
osx_image: xcode8
45+
env: CXX=clang++
46+
47+
install:
48+
- if [ "$TRAVIS_OS_NAME" == "osx" ]; then (brew install valgrind); fi
49+
50+
script:
51+
- mkdir build_debug && cd build_debug && cmake -DCMAKE_BUILD_TYPE=debug .. && make -j2 && ctest --output-on-failure && cd ..
52+
- mkdir build_debug_memcheck && cd build_debug_memcheck && cmake -DCMAKE_BUILD_TYPE=debug -DENABLE_MEMCHECK=ON .. && make -j2 && ctest --output-on-failure && cd ..
53+
- mkdir build_release && cd build_release && cmake -DCMAKE_BUILD_TYPE=release .. && make -j2 && ctest --output-on-failure && cd ..
54+
- mkdir build_release_memcheck && cd build_release_memcheck && cmake -DCMAKE_BUILD_TYPE=release -DENABLE_MEMCHECK=ON .. && make -j2 && ctest --output-on-failure && cd ..

CMakeLists.txt

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
#
2+
# Copyright (c) 2016-2017 Kris Jusiak (kris at jusiak dot net)
3+
#
4+
# Distributed under the Boost Software License, Version 1.0.
5+
# (See accompanying file LICENSE_1_0.txt or copy at
6+
# http://www.boost.org/LICENSE_1_0.txt)
7+
#
8+
cmake_minimum_required(VERSION 2.8)
9+
project(GUnit CXX)
10+
11+
option(ENABLE_MEMCHECK "Run the unit tests and examples under valgrind if it is found." OFF)
12+
13+
add_custom_target(style)
14+
add_custom_command(TARGET style COMMAND find ${CMAKE_CURRENT_LIST_DIR}/benchmark ${CMAKE_CURRENT_LIST_DIR}/example ${CMAKE_CURRENT_LIST_DIR}/include ${CMAKE_CURRENT_LIST_DIR}/test -iname "*.h" -or -iname "*.cpp" | xargs clang-format -i)
15+
16+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++1y")
17+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
18+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wextra")
19+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror")
20+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic")
21+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic-errors")
22+
23+
enable_testing()
24+
25+
add_subdirectory(libs/googletest)
26+
27+
include_directories(include)
28+
include_directories(${gtest_SOURCE_DIR}/include)
29+
include_directories(${gmock_SOURCE_DIR}/include)
30+
31+
set(BUILD_GMOCK)
32+
set(BUILD_GTEST)
33+
34+
find_program(MEMORYCHECK_COMMAND valgrind)
35+
if (ENABLE_MEMCHECK AND MEMORYCHECK_COMMAND)
36+
function(test name)
37+
string(REPLACE "/" "_" out ${name})
38+
add_executable(${out} ${CMAKE_CURRENT_LIST_DIR}/${name}.cpp)
39+
add_test(${out} ${MEMORYCHECK_COMMAND} --leak-check=full --error-exitcode=1 ./${out})
40+
target_link_libraries(${out} gtest_main)
41+
target_link_libraries(${out} gmock_main)
42+
endfunction()
43+
else()
44+
function(test name)
45+
string(REPLACE "/" "_" out ${name})
46+
add_executable(${out} ${CMAKE_CURRENT_LIST_DIR}/${name}.cpp)
47+
add_test(${out} ./${out})
48+
target_link_libraries(${out} gtest_main)
49+
target_link_libraries(${out} gmock_main)
50+
endfunction()
51+
endif()
52+
53+
test(test/GMock)
54+
test(test/GTest)
55+
test(example/GMock)
56+
test(example/GTest)
57+
58+
include_directories(benchmark)
59+
test(benchmark/GUnit/test)
60+
test(benchmark/gtest/test)

0 commit comments

Comments
 (0)