From 0ac7a8efa02c61926b13febd2d53e6372501d602 Mon Sep 17 00:00:00 2001 From: fedorov Date: Tue, 9 Apr 2019 23:43:46 +0300 Subject: [PATCH] add google tests support --- .../CMakeLists.txt | 12 +++- .../_readme_lab1.md | 2 + 1. Matrix multiplication in OpenMP/main.cpp | 1 - .../test/matrixTest.cpp | 60 +++++++++++++++++++ 4 files changed, 72 insertions(+), 3 deletions(-) create mode 100644 1. Matrix multiplication in OpenMP/test/matrixTest.cpp diff --git a/1. Matrix multiplication in OpenMP/CMakeLists.txt b/1. Matrix multiplication in OpenMP/CMakeLists.txt index 4b8bd2f..b39f27d 100644 --- a/1. Matrix multiplication in OpenMP/CMakeLists.txt +++ b/1. Matrix multiplication in OpenMP/CMakeLists.txt @@ -1,7 +1,15 @@ -cmake_minimum_required(VERSION 3.13) +cmake_minimum_required(VERSION 3.10) project(1__Matrix_multiplication_in_OpenMP) set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -fopenmp") -add_executable(1__Matrix_multiplication_in_OpenMP main.cpp Matrix/Matrix.cpp Matrix/Matrix.h) \ No newline at end of file +# Locate GTest +find_package(GTest REQUIRED) +include_directories(${GTEST_INCLUDE_DIRS}) + +# Link runTests with what we want to test and the GTest and pthread library +add_executable(executeTests test/matrixTest.cpp) +target_link_libraries(executeTests ${GTEST_LIBRARIES} pthread) + +add_executable(1__Matrix_multiplication_in_OpenMP main.cpp Matrix/Matrix.cpp Matrix/Matrix.h test/matrixTest.cpp) \ No newline at end of file diff --git a/1. Matrix multiplication in OpenMP/_readme_lab1.md b/1. Matrix multiplication in OpenMP/_readme_lab1.md index 1809d66..eafe77f 100644 --- a/1. Matrix multiplication in OpenMP/_readme_lab1.md +++ b/1. Matrix multiplication in OpenMP/_readme_lab1.md @@ -29,3 +29,5 @@ Task: 6) https://software.intel.com/ru-ru/articles/getting-started-with-openmp 7) https://software.intel.com/ru-ru/articles/more-work-sharing-with-openmp 8) https://en.wikipedia.org/wiki/SPMD + +9) [Google tests](https://www.srcmake.com/home/google-cpp-test-framework) \ No newline at end of file diff --git a/1. Matrix multiplication in OpenMP/main.cpp b/1. Matrix multiplication in OpenMP/main.cpp index dd34e4e..52b50f0 100644 --- a/1. Matrix multiplication in OpenMP/main.cpp +++ b/1. Matrix multiplication in OpenMP/main.cpp @@ -2,7 +2,6 @@ #include #include #include - #include #include "Matrix/Matrix.h" diff --git a/1. Matrix multiplication in OpenMP/test/matrixTest.cpp b/1. Matrix multiplication in OpenMP/test/matrixTest.cpp new file mode 100644 index 0000000..155ce79 --- /dev/null +++ b/1. Matrix multiplication in OpenMP/test/matrixTest.cpp @@ -0,0 +1,60 @@ +#include + +#include "../Matrix/Matrix.h" + +TEST(getNumRowsTest, getNumRowsTest) { + auto *matrix = new Matrix(4, 40); + ASSERT_EQ(4, matrix->getNumRows()); + delete(matrix); +} + +TEST(getNumColumnsTest, getNumColumnsTest) { + auto *matrix = new Matrix(4, 40); + ASSERT_EQ(40, matrix->getNumRows()); + delete(matrix); +} +// +//TEST(showFirstMatrix, showFirstMatrix) { +// +//} +// +//TEST(showSecondMatrix, showSecondMatrix) { +// +//} +// +//TEST(showResultMatrix, showResultMatrix) { +// +//} +// +//TEST(getExecutingTimeWithOmp, getExecutingTimeWithOmp) { +// +//} +// +//TEST(getExecutingTimeWithoutOmp, getExecutingTimeWithoutOmp) { +// +//} +// +//TEST(multiplyTwoMatricesWithOmpDefault, multiplyTwoMatricesWithOmpDefault) { +// +//} +// +//TEST(multiplyTwoMatricesWithOmpStatic, multiplyTwoMatricesWithOmpStatic) { +// +//} +// +//TEST(multiplyTwoMatricesWithOmpDynamic, multiplyTwoMatricesWithOmpDynamic) { +// +//} +// +//TEST(multiplyTwoMatricesWithOmpGuided, multiplyTwoMatricesWithOmpGuided) { +// +//} +// +//TEST(multiplyTwoMatricesWithOmpRuntime, multiplyTwoMatricesWithOmpRuntime) { +// +//} + +int main(int argc, char **argv){ + testing::InitGoogleTest(&argc, argv); + return RUN_ALL_TESTS(); +} \ No newline at end of file