googletest

undefined reference to `pthread_key_create' (linker error)

拈花ヽ惹草 提交于 2019-12-17 06:54:06
问题 I have downloaded gtest 1.7.0 sources from here: https://code.google.com/p/googletest/downloads/list and build the gtest .a files (lib files) on ubuntu 13.10: Linux ubuntu 3.11.0-15-generic #23-Ubuntu SMP Mon Dec 9 18:17:04 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux and the resulting lib is called: libgtest.a . In my main.cpp file Have: #include <iostream> #include "gtest/gtest.h" int main(){ std::cout << "Test \n"; int argc = 2; char* cp01; char* cp02; char* argv[] = {cp01, cp02}; testing:

CMake + GoogleTest

爱⌒轻易说出口 提交于 2019-12-17 02:07:12
问题 I just downloaded googletest, generated its makefile with CMake and built it. Now, I need to use it in my testing project. With CMake, I have been advised not pointing to gtest libraries directly (using include _directories or link_directories ) but use find_package() instead. The problem is, there is no install target for the gtest makefile generated. I cannot understand how find_package(GTest REQUIRED) could work without some kind of installation. Also, putting the gtest folder as a

How to set up Google C++ Testing Framework (gtest) with Visual Studio 2005

こ雲淡風輕ζ 提交于 2019-12-17 02:05:12
问题 It is not documented on the web site and people seem to be having problems setting up the framework. Can someone please show a step-by-step introduction for a sample project setup? 回答1: What Arlaharen said was basically right, except he left out the part which explains your linker errors. First of all, you need to build your application without the CRT as a runtime library. You should always do this anyways, as it really simplifies distribution of your application. If you don't do this, then

Why does CMake not find GTest (Google Test)?

爱⌒轻易说出口 提交于 2019-12-14 02:25:33
问题 There is a ready project. In one of the cmake-files there is a source code: find_package(GTest REQUIRED) if (NOT GTest_FOUND) message(FATAL_ERROR "Cannot find Google Test Framework!") endif() Gives an error: "Cannot find Google Test Framework!" How to fix error? 回答1: The FindGTest.cmake file uses the environment variable GTEST_ROOT . You can add this variable to your system or just add it to your CMakeLists.txt file: set(GTEST_ROOT "c:/path/to/gtest/root" CACHE PATH "path to gtest"). This

Using macros on functions in an array to make gtest typed-parameterized tests more succinct

北城余情 提交于 2019-12-13 07:51:04
问题 Right now, IMO, Google typed-parameterized tests are annoying. You have to do: template <typename fixtureType> class testFixtureOld : public ::testing::Test { }; // Tell google test that we want to test this fixture TYPED_TEST_CASE_P(testFixtureOld); // Create the tests using this fixture TYPED_TEST_P(testFixtureOld, OIS1Old) { TypeParam n = 0; EXPECT_EQ(n, 0); } TYPED_TEST_P(testFixtureOld, OIS2Old) { TypeParam n = 0; EXPECT_EQ(n, 0); } // Register the tests we just made REGISTER_TYPED_TEST

googletest testing framework c++: static method linker error

…衆ロ難τιáo~ 提交于 2019-12-13 07:06:30
问题 I'm trying to call static method from my TEST, but I'm getting unresolved external symbol. What I've done so far: Created 3 projects: GoogleTest project as a static library - compiled gtest-all.cc and gtest_main.cc MyProject - where I keep my .h and .cpp files UnitTest project - where I keep tests I've set up UnitTest's additional directories, lib directories, and referenced GoogleTest and MyProject. Tests run fine until I call static method from one of my classes... Linker options: /OUT:"D:

GoogleTest Fixture for blitz++ class with arguments in constructor

假如想象 提交于 2019-12-13 02:48:06
问题 I have got a question that is related to this one: GTest fixture when constructor takes parameters?. I that question I wanted to know how to set up a GTest fixture when the tested class takes a parameter for the constructor. I tried to replicate the answer for blitz++ instead of arma, and I fail. Any clues? The test class: #include <blitz/array.h> #include <vector> class TClass { private: std::vector<blitz::Array<double,2> * > mats; public: TClass(std::vector<blitz::Array<double,2> * > m_);

Project Makefile problems with Google Test

自作多情 提交于 2019-12-12 23:18:03
问题 For the life of me I cannot figure out how to remove the mv statements in the following makefile TEST_DIR = ../gtest USER_DIR = src TESTS_DIR = tests OBJ_DIR = obj CPPFLAGS += -isystem $(GTEST_DIR)/include -I$(USER_DIR) CXXFLAGS += -g -Wall -Wextra TESTS = test GTEST_HEADERS = $(GTEST_DIR)/include/gtest/*.h \ $(GTEST_DIR)/include/gtest/internal/*.h all : $(TESTS) clean : rm -rf obj rm -rf bin mkdir obj mkdir bin GTEST_SRCS_ = $(GTEST_DIR)/src/*.cc $(GTEST_DIR)/src/*.h $(GTEST_HEADERS) $(OBJ

Improving the build times for Google Test test cases in NetBeans IDE

一曲冷凌霜 提交于 2019-12-12 15:27:39
问题 I am using Google Test 1.7.0 in NetBeans IDE 7.3.1 on a Microsoft Windows 7 operating system together with Minimalist GNU for Windows. To make test cases run from inside the IDE, I followed this YouTube video. Everything works fine, but running (more exactly building) the tests is horribly slow. To conclude: I've build Google Test and Google Mock as a static library. Both are not rebuilt on running the tests. Both static libraries are linked for the test files only and together with POSIX

googletest: performing additional operation if test fail

风格不统一 提交于 2019-12-12 10:55:39
问题 I'd like to be able to save data to disk in case the test fails. Is there any way to do it within the googletest framework? TEST_F(test_similarity,are_similar) { ASSERT_GT(1e-10,norm(im0,im1)); // If test fails save images to disk for comparison: imwrite("im0.png",im0); imwrite("im1.png",im1); } 回答1: There are the Test::HasFailure() , Test::HasNonfatalFailure() and Test::HasFatalFailure() functions, that return true if there was a (fatal/non-fatal) failure. You could use them to check. TEST_F