googletest Questions

2

Solved

I'm trying to get a working googletest test that compares two vectors. For this I'm using google mock with its matchers but I get a C3861 error saying "ContainerEq identifier not found" a...
Hive asked 9/9, 2012 at 15:42

2

It's the first time I want to use unit tests in my c++ project. Hence I've many existing classes for which I will write tests (at least for some of them). Further, the application has of course a m...
Affectation asked 26/1, 2017 at 22:7

14

Solved

I want to test that MyException is thrown in a certain case. EXPECT_THROW is good here. But I also want to check the exception has a specific state e.g e.msg() == "Cucumber overflow". How is this ...
Hydrosol asked 24/4, 2014 at 13:16

1

Solved

I would like to be able to parameterize my tests for various types through the following code snippet: template <typename T> class MyTestSuite : public testing::TestWithParam<tuple<T, v...
Boaster asked 18/7, 2022 at 6:48

3

Solved

I want to create a Bazel C++ project with gtest for unit tests. What is the minimal setup? (I only have Bazel installed on my computer and I am running under Linux)
Lection asked 22/8, 2017 at 10:5

1

Solved

Background: I'm mocking a hardware i2c transmit function, and trying to match on an array passed into it. This is in an embedded context, hence the c-style arrays and lack of STL containers. Trying...
Psychotechnology asked 12/6, 2022 at 12:26

1

I am new to Cmake and Gtest. I have a problem with in CMake find_package(GMock REQUIRED) and target_link_libraries(runtest ${GMOCK_BOTH_LIBRARIES} pthread). When I build the project, CMake is...
Tarsia asked 9/4, 2018 at 15:15

0

I was wondering if it's a good practice to insert performance test and measurment in the test phase of the build for a c++ project. In my project I have some methods for which I have some execution...
Injurious asked 26/4, 2022 at 18:24

2

Solved

I want to test a template class with gtest. I read about TYPED_TESTs in Google Test manual and looked at official example they reference, but still can't wrap my head around getting an object of te...
Represent asked 13/6, 2013 at 5:17

7

Solved

I'm trying to use GoogleTest on Android Studio. According to what I understood, the latest version of NDK has the gtest included. I did not find a clear guide how to do it. I followed this docum...
Stanza asked 26/9, 2017 at 15:3

2

Solved

I've written a Google Test like the one below which compares some computed values with the one expected stored in a CSV file. class SampleTest : public ::testing::Test{ public: void setupFile(co...
Bridgid asked 20/12, 2018 at 19:51

3

Solved

I want to mock a method that returns a complex datatyp class aClass { public: virtual const QMap<QString, QString> aMethod() const; } class MockaClass : public aClass { public: MOCK_CONST...
Cacomistle asked 18/4, 2012 at 10:25

4

Solved

I am unable to use Google Test's ASSERT_THROW() macro in combination with multiple template arguments. Consider that I want to make sure that construction of Matrix<5,1> throws: ASSERT_THROW...
Photography asked 21/12, 2010 at 6:42

6

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 additio...
Subteen asked 28/10, 2011 at 0:16

3

Solved

I just started working on unit testing (using BOOST framework for testing, but for mocks I have to use Google Mock) and I have this situation : class A { static int Method1(int a, int b){return a...
Andromada asked 20/1, 2012 at 13:44

10

Solved

I am looking to compare two arrays in google test. In UnitTest++ this is done through CHECK_ARRAY_EQUAL. How do you do it in google test?
Genitalia asked 22/9, 2009 at 15:12

2

Solved

I am trying to integrate Google Test into the subproject of bigger project and I cannot find the solution that would be satisfying for me. I have two constraints: the source code of Google Test is...
Crayfish asked 18/5, 2018 at 9:32

2

Solved

At the end of every "file based integration" test, I want to clear a temp folder of associated files. If the test fails, I want to leave the files there, so I can review the unexpected output. Is...
Sluggard asked 16/3, 2017 at 9:12

9

I'm trying to install gtest with my packet manager Home Brew but there is no repository for it. I tried to download gtest from code.google but I can't understand how to install it, because cmake an...
Grapher asked 6/4, 2013 at 15:21

1

How can I force google test compile with /MT option? I saw that google test tries to compile with MT(internal_utils.cmake line 33): if (NOT BUILD_SHARED_LIBS AND NOT gtest_force_shared_crt) strin...
Pride asked 16/9, 2020 at 17:35

6

Is there an option to show only failed tests? I had to switch to use Guitar to achieve this, but I miss command line tool.
Awestricken asked 7/7, 2011 at 2:56

2

Solved

I am using gtest but I am new to gtest. I would like to do compares of values within two std::vectors of complex data structures. I want to do something like this: ASSERT_EQ(a.size(), b.size()); ...
Poor asked 13/6, 2018 at 18:23

4

Solved

How to mock a method with optional parameter in Google Mock? For example: class A { public: void set_enable( bool enabled = true ); }; class MockA : public A { MOCK_METHOD1( set_enable, void(...
Quart asked 21/7, 2016 at 9:30

3

Solved

I'm trying to write a test suite that performs a test-suite level "Set Up" operation. I attempted to write a simple program first to try and get it working but I am not having any luck getting the...

4

I have a data structure which is being notified to a listener. Among its many variables, it has an optional double which represents an angle: struct Data { // ...other data fields std::optional&l...
Lock asked 25/8, 2020 at 10:20

© 2022 - 2024 — McMap. All rights reserved.