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

  • Home
  • SEARCH
  • 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 8636755
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T10:18:12+00:00 2026-06-12T10:18:12+00:00

I implemented a googletest, with fixture class UnitTest_solver . Implementation for the fixture is

  • 0

I implemented a googletest, with fixture class UnitTest_solver. Implementation for the fixture is the following. It contains helper functions

class UnitTest_solver : public ::testing::Test
{

protected:

    static void SetUpTestCase()
    {
        // setup table with data
        m_col = 2; 
        m_row = 100;
        //  other things to initialize m_test_data 
    }



    static void TearDownTestCase()
    {
        for(int i = 0 ; i < m_row ; i++)
            delete[] m_test_data[i];
        delete[] m_test_data;
    }



    static double chi_sqr(double* x)
    {
        if(m_col < 2)
            return 0;

        double fx = 0;

        double * row_i = new double[m_col - 1];

        for(int i = 0 ; i < m_row ; i++)
        {
            for(int j = 0 ; j < m_col - 1 ; j++)
                row_i[j] = m_test_data[i][j];

            fx += pow(m_test_data[i][0] - func_1(x, row_i, m_col - 1), 2.0); 
        }
    return fx;
    }


    static double func_1(double* x, double* dbl, int nb_param)
    {
        if(nb_param != 2)
            return 0;

        return x[0] * exp(-1 * x[1] * dbl[0]);
    }

    static double UnitTest_solver::functPtr( double * parameters, void * userinfo)
    {
        return  chi_sqr(parameters);
    }

    static ofstream thing;
    static double** m_test_data;
    static int m_col, m_row;

 };

Also, out of the fixture scope, i initialize static variables. Last is function pointer. is definition syntax ok ?

double** UnitTest_solver::m_test_data = 0;
int UnitTest_solver::m_col = 0;
int UnitTest_solver::m_row = 0;

double (UnitTest_solver::*functPtr)(double * , void *) = 0;

then, i have a test case, with link to fixture UnitTest_solver.

TEST_F(UnitTest_solver, testFunc1)
{
    Solver* solversqp = new Solver();
    solversqp->set_pointer_to_function(UnitTest_solver::functPtr, (void*)0);
    //...
}

second line show compile time error with UnitTest_solver::functPtr : when mouse is over the error, info is ‘function defined at line xxx is unacessible’, with xxx pointing to functPtr definition inside the fixture.

If i run the ggltest commenting the last line, solversqp->set_pointer_to_function(UnitTest_solver::functPtr, (void*)0);, test is finishing (if i put a trivial ASSERT, it is successful).

Whats wrong with my function pointer definition.

  • 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-12T10:18:13+00:00Added an answer on June 12, 2026 at 10:18 am

    I do not see full code, therefore this is just a guess.

    Everything in class UnitTest_solver is protected, therefore everything (other then classes inheriting for this class) do not have access to it’s members. Change it to public, and your problem will be solved :

    class UnitTest_solver : public ::testing::Test
    {
    
    // protected: 
    public:
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I implemented class that serves as TcpCLient server. Looks like this: { [Export] public
I implemented Simple Lua class in C. Usage of class: require(test) function foo() local
Implemented a generic repository with several Methods. One of those is this: public IEnumerable<T>
We implemented In-app Billing one year ago with no problems following the sample code
I implemented simple server-client chat in Java. Here the source for the server: public
I implemented a ListView using ArrayAdapter. Each listItem (row) contains EditText. When I try
I implemented the following code, which does what it's supposed to, but I think
Implemented the Sink Class - to receive event notifications from COM Server Event Interface
I implemented the following code: NSURL *url = [ NSURL URLWithString:[ NSString stringWithFormat: @http://www.google.com/search?q=%@,
I implemented the following delegate method for NSTextField to add autocompletion support: - (NSArray

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.