Skip to content

Commit 3324d43

Browse files
author
alexander.iljin
committed
Add test
1 parent 5d861a6 commit 3324d43

File tree

7 files changed

+74
-22
lines changed

7 files changed

+74
-22
lines changed

.travis.yml

+10-10
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,16 @@ script:
88
- bash ./.travis/run.sh
99

1010
env:
11-
- BUILD_TYPE=Release COMPILER=g++-4.9
12-
- BUILD_TYPE=Release COMPILER=g++-5
13-
- BUILD_TYPE=Release COMPILER=g++-6
14-
- BUILD_TYPE=Release COMPILER=clang++-3.9
15-
- BUILD_TYPE=Release COMPILER=clang++-4.0
16-
- BUILD_TYPE=Debug COMPILER=g++-4.9
17-
- BUILD_TYPE=Debug COMPILER=g++-5
18-
- BUILD_TYPE=Debug COMPILER=g++-6
19-
- BUILD_TYPE=Debug COMPILER=clang++-3.9
20-
- BUILD_TYPE=Debug COMPILER=clang++-4.0
11+
- BUILD_TYPE=Release C_COMPILER=gcc-4.9 CXX_COMPILER=g++-4.9
12+
- BUILD_TYPE=Release C_COMPILER=gcc-5 CXX_COMPILER=g++-5
13+
- BUILD_TYPE=Release C_COMPILER=gcc-6 CXX_COMPILER=g++-6
14+
- BUILD_TYPE=Release C_COMPILER=clang-3.9 CXX_COMPILER=clang++-3.9
15+
# - BUILD_TYPE=Release C_COMPILER=clang-4.0 CXX_COMPILER=clang++-4.0
16+
- BUILD_TYPE=Debug C_COMPILER=gcc-4.9 CXX_COMPILER=g++-4.9
17+
- BUILD_TYPE=Debug C_COMPILER=gcc-5 CXX_COMPILER=g++-5
18+
- BUILD_TYPE=Debug C_COMPILER=gcc-6 CXX_COMPILER=g++-6
19+
- BUILD_TYPE=Debug C_COMPILER=clang-3.9 CXX_COMPILER=clang++-3.9
20+
# - BUILD_TYPE=Debug C_COMPILER=clang-4.0 CXX_COMPILER=clang++-4.0
2121

2222
addons:
2323
apt:

CMakeLists.txt

+8-1
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,16 @@ project(hello CXX)
55
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
66
conan_basic_setup()
77

8+
include_directories(include)
9+
810
set(${PROJECT_NAME}_SRC
911
src/main.cpp
1012
)
1113

12-
add_executable(${PROJECT_NAME} ${${PROJECT_NAME}_SRC})
14+
add_library(${PROJECT_NAME} ${${PROJECT_NAME}_SRC})
1315
target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS})
16+
17+
set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 14)
18+
19+
enable_testing()
20+
add_subdirectory(test)

appveyor.yml

+10-8
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@ install:
55
- set PATH=%PATH%;%PYTHON%/Scripts/
66
- pip.exe install conan
77
- mkdir build && cd build
8-
- conan install .. --build=missing -s build_type=%BUILD_TYPE% -s compiler="Visual Studio" -s compiler.version=%TOOLCHAIN_VERSION%
8+
- conan install .. --build=missing -s build_type=%BUILD_TYPE% -s compiler="Visual Studio" -s compiler.version=%TOOLCHAIN_VERSION% -s compiler.runtime=%RUNTIME%
99

1010
build_script:
1111
- cmake -G "Visual Studio %TOOLCHAIN_VERSION% Win64" ..
12-
- cmake --build . --config %BUILD_TYPE%
12+
- cmake --build . --config %BUILD_TYPE%
1313

1414
test_script:
15-
- cmd: "%BUILD_TYPE%\\hello"
15+
- cmd: ctest -V -C %BUILD_TYPE%
1616

1717
environment:
1818
PYTHON: "C:\\Python27"
@@ -21,17 +21,19 @@ environment:
2121
matrix:
2222
- TOOLCHAIN_VERSION: 14
2323
BUILD_TYPE: Release
24+
RUNTIME: MD
2425
- TOOLCHAIN_VERSION: 12
2526
BUILD_TYPE: Release
26-
- TOOLCHAIN_VERSION: 11
27-
BUILD_TYPE: Release
27+
RUNTIME: MD
2828
- TOOLCHAIN_VERSION: 10
2929
BUILD_TYPE: Release
30+
RUNTIME: MD
3031
- TOOLCHAIN_VERSION: 14
3132
BUILD_TYPE: Debug
33+
RUNTIME: MDd
3234
- TOOLCHAIN_VERSION: 12
3335
BUILD_TYPE: Debug
34-
- TOOLCHAIN_VERSION: 11
35-
BUILD_TYPE: Debug
36+
RUNTIME: MDd
3637
- TOOLCHAIN_VERSION: 10
37-
BUILD_TYPE: Debug
38+
BUILD_TYPE: Debug
39+
RUNTIME: MDd

include/hello/hello.h

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#ifndef HELLO_HELLO_H
2+
#define HELLO_HELLO_H
3+
4+
#include <ostream>
5+
6+
namespace hello {
7+
std::ostream& greet(std::ostream&);
8+
}
9+
#endif

src/main.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
#include <iostream>
1+
#include <hello/hello.h>
22

3-
int main() {
4-
std::cout << "Hello, world!" << std::endl;
3+
std::ostream& hello::greet(std::ostream& stream) {
4+
return stream << "Hello, world";
55
}

test/CMakeLists.txt

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
cmake_minimum_required(VERSION 2.8.7)
2+
3+
project(test_hello CXX)
4+
5+
set(${PROJECT_NAME}_SRC
6+
test_hello.cpp
7+
)
8+
9+
add_executable(${PROJECT_NAME} ${${PROJECT_NAME}_SRC})
10+
11+
target_link_libraries(${PROJECT_NAME}
12+
hello
13+
${CONAN_LIBS}
14+
)
15+
16+
set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 14)
17+
18+
add_test(NAME ${PROJECT_NAME}
19+
COMMAND ${PROJECT_NAME})

test/test_hello.cpp

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#include <sstream>
2+
3+
#include <gtest/gtest.h>
4+
5+
#include <hello/hello.h>
6+
7+
using namespace hello;
8+
9+
TEST(hello, hello) {
10+
std::stringstream ss;
11+
12+
greet(ss);
13+
14+
ASSERT_EQ("Hello, world", ss.str());
15+
}

0 commit comments

Comments
 (0)