googletest

How to test c++ template class with multiple template parameters using gtest?

牧云@^-^@ 提交于 2019-11-29 02:14:46
I want to test a template class with gtest. I read about TYPED_TEST s in gtest manual and looked at the official example ( samples\sample6_unittest.cc ) they reference. This template from the example has only one template parameter. But, my code has two template parameters, how can I test it? I have the following code: // two element type template <typename E, typename F> class QueueNew { public: QueueNew() {} void Enqueue(const E& element) {} E* Dequeue() {} F size() const { return (F)123; } }; for which I wrote the test code below: template <class E, class F> QueueNew<E, F>* CreateQueue();

Why is GoogleMock leaking my shared_ptr?

倖福魔咒の 提交于 2019-11-29 01:03:35
I use GoogleMock/GoogleTest for testing, and I'm seeing some strange behavior when a matcher has a shared_ptr to a mock as a parameter, and EXPECT is called on the same shared_ptr. The offending piece of code: #include <gmock/gmock.h> #include <gtest/gtest.h> #include <boost/shared_ptr.hpp> #include <boost/make_shared.hpp> using namespace boost; using namespace testing; struct MyParameter { virtual ~MyParameter() {} virtual void myMethod() = 0; }; struct MyParameterMock : public MyParameter { MOCK_METHOD0(myMethod, void()); }; struct MyClass { virtual ~MyClass() {} virtual void myMethod(shared

wxWidgets: How to initialize wxApp without using macros and without entering the main application loop?

两盒软妹~` 提交于 2019-11-29 00:42:34
问题 We need to write unit tests for a wxWidgets application using Google Test Framework . The problem is that wxWidgets uses the macro IMPLEMENT_APP(MyApp) to initialize and enter the application main loop. This macro creates several functions including int main() . The google test framework also uses macro definitions for each test. One of the problems is that it is not possible to call the wxWidgets macro from within the test macro, because the first one creates functions.. So, we found that we

Unable to get hudson to parse JUnit test output XML

你离开我真会死。 提交于 2019-11-29 00:28:18
EDIT : This issue has been fixed by google in gtest 1.4.0; see the original bug report for more information. I've recently switched to gtest for my C++ testing framework, and one great feature of it which I am presently unable to use is the ability to generate JUnit-style XML test reports, which could then be read in by our hudson build server. The XML output generated by the gtest test suite all looks legit: <?xml version="1.0" encoding="UTF-8"?> <testsuite tests="370" failures="0" disabled="0" errors="0" time="45.61" name="AllTests"> <testsuite name="application" tests="7" failures="0"

How to use googletest Failures into Break-Points

删除回忆录丶 提交于 2019-11-29 00:20:47
问题 I recently discovered the Failures into Break-Points - option from googletest using the command line option gtest_break_on_failure or by defining the GTEST_BREAK_ON_FAILURE environment variable. I gave it a try using gtest_break_on_failure . From command line, I saw no effect (to be honest I had the glimpse of hope that VS2010 would be registered as debugger and somehow magically would pop up and point to the error source). Using it in the VS environment as command line argument a failed

google-test: code coverage

本秂侑毒 提交于 2019-11-28 23:55:54
问题 Is it possible to get code coverage done by tests using google test framework? 回答1: Yes, I've successfully used both free (gcov) and commercial (CTC++) tools. No special steps are needed, just follow the documentation. More details can be found in this blog http://googletesting.blogspot.dk/2014/07/measuring-coverage-at-google.html 回答2: Yes, You can club your Gtest Based application with support of Gcov/lcov. refer the documentation of lcov http://ltp.sourceforge.net/coverage/lcov.php there is

Printing additional output in Google Test

℡╲_俬逩灬. 提交于 2019-11-28 23:36:20
问题 I'm using the googletest C++ testing framework. Normally the textual output of running a test looks like this: [ RUN ] MyTest.Fuzz [ OK ] MyTest.Fuzz (1867 ms) I would like to output some additional data in the same format, for example: [ RUN ] MyTest.Fuzz [ ] random seed = 1319760587 [ OK ] MyTest.Fuzz (1867 ms) I have found Logging Additional Information in the googletest documentation but that only seems to send structured data to the XML output, not the standard console output. Is there a

error during making GTest

十年热恋 提交于 2019-11-28 22:26:54
I was trying to set up GTest environment on my Ubuntu machine. but while making the GTest to get the library, i get the following error... som@som-VPCEH25EN:~/Workspace/CPP/gtest-1.6.0/make$ make g++ -I../include -g -Wall -Wextra -lpthread sample1.o sample1_unittest.o gtest_main.a -o sample1_unittest gtest_main.a(gtest-all.o): In function `~ThreadLocal': /home/som/Workspace/CPP/gtest-1.6.0/make/../include/gtest/internal/gtest-port.h:1336: undefined reference to `pthread_getspecific' /home/som/Workspace/CPP/gtest-1.6.0/make/../include/gtest/internal/gtest-port.h:1340: undefined reference to

Using gtest in jenkins

旧城冷巷雨未停 提交于 2019-11-28 22:25:42
问题 I successfully run my unit test with google test in Jenkins, but I don't know how to show the .xml file generated by gtest. It is said that gtest satisfies the JUnit format, so what I set is as follows: But it ends up with errors after a building. No test report files were found. Configuration error? Build step 'Publish JUnit test result report' changed build result to FAILURE Finished: FAILURE 回答1: Fraser's answer is good and you need some extra processing to convert the gtest XML to proper

Is Google Test OK for testing C code?

元气小坏坏 提交于 2019-11-28 21:53:54
问题 So I've come to like and enjoy using Google Test for a C++ project I'm involved in. I'm just bringing up a new project that will be straight C (a library) and so far can't see any reason why not to continuing using Google Test, even though its a C++ framework. Having a C++ compiler available will not be an issue. Are there are specific reasons why I shouldn't use Google Test for testing straight C code? Thanks. 回答1: It is pretty common to test C code using a C++ testing frameworks, even the