Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9185591
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T19:18:54+00:00 2026-06-17T19:18:54+00:00

I’ve just learned about value-parametrized unit tests in googletest and would like to use

  • 0

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-generated constructor stub

}

ParametrizedGTest::~ParametrizedGTest() {
    // TODO Auto-generated destructor stub
}


TEST_P(ParametrizedGTest, testParameter) {
    int n = GetParam();
    EXPECT_EQ(n, GetParam());
}


INSTANTIATE_TEST_CASE_P(ParametrizedGTestInstance,
                        ParametrizedGTest,
                        ::testing::Values(100));

} /* namespace EnsembleClustering */

Now, when I run googletest as usual, the program crashes without any output. The gdb stack trace is

EnsembleClustering-D [C/C++ Application]    
    EnsembleClustering  
        Thread [1] (Suspended : Signal : EXC_BAD_ACCESS:Could not access memory)    
            __gnu_debug::_Safe_sequence_base::_M_attach_single() at 0x100528add 
            __gnu_debug::_Safe_sequence_base::_M_attach() at 0x100528a74    
            __gnu_debug::_Safe_iterator_base::_M_attach() at 0x100528bfe    
            __gnu_debug::_Safe_iterator_base::_Safe_iterator_base() at safe_base.h:90 0x1000016e9   
            __gnu_debug::_Safe_iterator<__gnu_cxx::__normal_iterator<testing::internal::ParameterizedTestCaseInfoBase**, std::__cxx1998::vector<testing::internal::ParameterizedTestCaseInfoBase*, std::allocator<testing::internal::ParameterizedTestCaseInfoBase*> > >, std::__debug::vector<testing::internal::ParameterizedTestCaseInfoBase*, std::allocator<testing::internal::ParameterizedTestCaseInfoBase*> > >::_Safe_iterator() at safe_iterator.h:154 0x100002e9c    
            std::__debug::vector<testing::internal::ParameterizedTestCaseInfoBase*, std::allocator<testing::internal::ParameterizedTestCaseInfoBase*> >::begin() at vector:207 0x100001fbe  
            testing::internal::ParameterizedTestCaseRegistry::GetTestCasePatternHolder<EnsembleClustering::ParametrizedGTest>() at gtest-param-util.h:574 0x1000025b0   
            EnsembleClustering::ParametrizedGTest_testParameter_Test::AddToRegistry() at ParametrizedGTest.cpp:22 0x100001d3f   
            __static_initialization_and_destruction_0() at ParametrizedGTest.cpp:22 0x100001349 
            _GLOBAL__sub_I_ParametrizedGTest.cpp() at ParametrizedGTest.cpp:32 0x100001424  
            <...more frames...> 
    gdb 

Am I doing something wrong or is this a bug in googletest? Can you reproduce this error?

EDIT: I am on Mac OS X 10.8.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T19:18:56+00:00Added an answer on June 17, 2026 at 7:18 pm

    From looking at the source code of gtest the only case if there are no parametrized tests available is on Windows using VC7.1 with disabled exceptions:

    // We don't support MSVC 7.1 with exceptions disabled now.  Therefore
    // all the compilers we care about are adequate for supporting
    // value-parameterized tests.
    #define GTEST_HAS_PARAM_TEST 1
    

    So, you’ll need to check how your MinGW was built and probably update it? And can you run the gtest unit tests to see if they execute the typed parameters test?

    More information on MinGW:

    On their FAQ they report that when using MinGW the following compile option for building gtest is required: PATH/TO/configure CC="gcc -mno-cygwin" CXX="g++ -mno-cygwin".

    Complete Example:

    #include <gtest/gtest.h>
    namespace EnsembleClustering {
    
        class ParametrizedGTest: public testing::TestWithParam<int> {
        public:
            ParametrizedGTest();
            virtual ~ParametrizedGTest();
        };
    
        ParametrizedGTest::ParametrizedGTest() {
        }
    
        ParametrizedGTest::~ParametrizedGTest() {
        }
    
        TEST_P(ParametrizedGTest, testParameter) {
            int n = GetParam();
            EXPECT_EQ(n, GetParam());
        }
    
        INSTANTIATE_TEST_CASE_P(ParametrizedGTestInstance,
                                ParametrizedGTest,
                                ::testing::Values(100));
    
    } /* namespace EnsembleClustering */
    
    
    int main(int argc, char* argv[]) {
        ::testing::InitGoogleTest(&argc, argv);
        return RUN_ALL_TESTS();
    }
    

    I compiled this code using the following compiler call on Mac OS X 10.8:

    g++ -IGTEST_INCLUDE_DIR -LGTEST_LIB_DIR -lgtest -o tt2 tt2.cpp
    

    Where GTEST_INCLUDE_DIR and GTEST_LIB_DIR are the path where header and library files are stored. When you compile and execute, what happens?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to run a str_replace or preg_replace which looks for certain words
I would like my Web page http://www.gmarks.org/math_in_e-mail.txt on my Apache 2.2.14 server to display
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I would like to count the length of a string with PHP. The string
I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am confused How to use looping for Json response Array in another Array.
I am trying to understand how to use SyndicationItem to display feed which is
I've got a string that has curly quotes in it. I'd like to replace

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.