googletest

Google Test macros seem not to work with Lambda functions

六眼飞鱼酱① 提交于 2019-12-11 07:59:28
问题 So, I have the following bit of code. Regardless of what the details of the Interpolator class are, it should in this case NOT throw an exception and that is what I wanted to test. TEST(errorhandlingInterpolator, toolargeInput) { const size_t numSamples = 100000; std::array<double, numSamples> bf{{0.0, 0.5, 1.0, 0.0, 0.5, 0.0}}; std::array<double, numSamples> ts{{0.0, 0.0, 0.0, 0.5, 0.5, 1.0}}; std::array<double, numSamples> current{ {0.13, 0.83, 0.96, 0.22, 0.30, 0.54} }; ASSERT_NO_THROW( [&

C++ Cmake build with cotire and gtest - error with float.h

拟墨画扇 提交于 2019-12-11 07:55:58
问题 I have a cmake build that uses gtest - everything works as expected. When I add cotire in I get the error: error: use of undeclared identifier 'DBL_MAX' Anywhere #import <float.h> is used It seems to me that some setting is being fubar'd by adding cotire, but the environment variables look roughly the same https://gist.github.com/anonymous/259e824359b7b399bc10f7aefd30b827 Am I missing something obvious? 来源: https://stackoverflow.com/questions/46734274/c-cmake-build-with-cotire-and-gtest-error

How to compare special fields in google mock?

冷暖自知 提交于 2019-12-11 07:29:46
问题 I have got question connected with google test. I would like to ask if while inducing "EXPECT_CALL(*A, some_method(mes1));" in test case there is possiblity to compare fields included in mes1 class. struct Mes { int a; }; //short section of test case: Mes mes1 = Mes(); EXPECT_CALL(*A, some_method(mes1)); I would like to ask if in google mock is a possiblity to compare special fields included in Mes. Something like: EXPECT_CALL(*A, some_method(mes1), compare(Mes.a));//in this case google mock

Unit testing: Am I doing right when using another method in unit testing a method?

假装没事ソ 提交于 2019-12-11 04:39:52
问题 To my best knowledge, unit testing should be done on each public API separately. But, I have been experiencing with a situation in which I have not found out a clear way to unit test each API independently as shown in the following example: class MyStorage { private: std::vector<int> int_vec_; public: bool insert_int(int value); int get_value_at(int idx); } I used GooogleTest framework and wrote unit tests as follows: int int_tenth(int x) { return x * 10; } TEST_F(MyStorageTest, insert_int) {

Build Google Test like shared library

我的未来我决定 提交于 2019-12-11 04:28:46
问题 I have the project with many subprojects, and one of them is google test project. I must build google test library as shared library every time when I build the main project, but single way to build the google test as shared is setting global option " BUILD_SHARED_LIBS=ON ". Unfortunately, other projects are depended of this option. So, how to build google test as shared library in this case? I tried to replace cxx_library(gtest "${cxx_strict}" src/gtest-all.cc) cxx_library(gtest_main "${cxx

Cant get gtest working with Xcode 6.2

老子叫甜甜 提交于 2019-12-11 03:49:03
问题 I'm trying to follow the instructions from Here. The instructions seem very straight forward, but I can't get it to compile. If I download the gtest file from the website, it appears there are header files missing from the include directory which means they don't get into the gtest-framework. the files are the gtest-port-arch.h and everything in the internal/custom folder. I get complier errors that these files are not found. If I get the source from the svn, all of the files are present in

Googletest Parametrized tests crash

不羁的心 提交于 2019-12-11 02:07:13
问题 I've just learned about value-parametrized unit tests in googletest and would like to use them in my project. I wrote a simple parametrized test. Header: #include <gtest/gtest.h> namespace EnsembleClustering { class ParametrizedGTest: public testing::TestWithParam<int> { public: ParametrizedGTest(); virtual ~ParametrizedGTest(); }; } /* namespace EnsembleClustering */ Source: #include "ParametrizedGTest.h" namespace EnsembleClustering { ParametrizedGTest::ParametrizedGTest() { // TODO Auto

Bad Reloc Address using MinGW

こ雲淡風輕ζ 提交于 2019-12-11 01:49:02
问题 I use MinGW on Windows 7 64bit. I used Google Test with NetBeans (followed Bo Qian instruction: http://www.youtube.com/watch?v=TS2CTf11k1U&feature=c4-overview-vl&list=PL5jc9xFGsL8GyES7nh-1yqljjdTvIFSsh&hd=1) and it worked correctly. Recently I tried to link Google Mock (with Google Test inside) to my project. I used Cmake and this is my CmakeLists.txt file: CMAKE_MINIMUM_REQUIRED(VERSION 2.8) PROJECT(FS_Report) INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}) SET(CMAKE_CXX_FLAGS_DEBUG "-g -Wall

Building assimp 3.2 does not work anymore

大憨熊 提交于 2019-12-10 22:59:58
问题 I can't build assimp 3.2 anymore. Yesterday it worked but today it doesn't. I am downloading assimp from here. Then I'm doing cmake CMakeLists.txt -G 'Unix Makefiles' and make as described in their INSTALL file. However when doing make I get the following error: [ 84%] Performing configure step for 'gtest' CMake Error at /home/gartenriese/Documents/assimp/assimp-3.2/test/gtest/src/gtest-stamp/gtest-configure.cmake:16 (message): Command failed: 1 '/usr/bin/cmake' '-DCMAKE_BUILD_TYPE=' '-Dgtest

How can I test a call is made after a delay in google test using a mocking framework

南笙酒味 提交于 2019-12-10 22:47:44
问题 I'm currently trying to evaluate different testing frameworks. When using mocking frameworks (I'm leaning towards FakeIt, but google mock is good too), I know that you can roll your own "performance" testing by using the OS's timer calls before and after calling a function to verify the function's performance. This is not what I'm after. What I do have are classes that implement delays on outputs given certain inputs. For example: input 1 goes from low to high output 1 goes from low to high