Last active
December 23, 2016 17:40
-
-
Save ashe23/8b37db05adedecf2366d24e7ebd95416 to your computer and use it in GitHub Desktop.
Google Test with cmake
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| GoogleTest link - https://github.com/google/googletest |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| cmake_minimum_required(VERSION 3.6) | |
| project(sandbox) | |
| add_subdirectory(googletest-master) | |
| include_directories(googletest-master/googletest/include) | |
| include_directories(googletest-master/googlemock/include) | |
| set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") | |
| set(SOURCE_FILES main.cpp SimpleTest.cpp) | |
| add_executable(sandbox ${SOURCE_FILES}) | |
| target_link_libraries(sandbox gtest gtest_main) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <gtest/gtest.h> | |
| #include <gmock/gmock.h> | |
| using namespace std; | |
| int main(int argc, char *argv[]) { | |
| //Initializing GoogleTest | |
| testing::InitGoogleTest(&argc, argv); | |
| RUN_ALL_TESTS(); | |
| return 0; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <gtest/gtest.h> | |
| #include <gmock/gmock.h> | |
| using testing::Eq; | |
| TEST(ShouldReturn2, toBe2) { | |
| EXPECT_EQ(2, 2); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment