Submit and vote on feature ideas.

Welcome to the new Parasoft forums! We hope you will enjoy the site and try out some of the new features, like sharing an idea you may have for one of our products or following a category.

About Stub function

lintu
lintu Posts: 5

Hi everyone,
I am a newbie here and I surfed lots of articles in 'help contents', but still got little sense about stub functions. Suppose that I have a source data library and use it in a Test Case writen by my own. And I want to know more information(for instance, the variable values calculated in one section inside the tested function). But my Test Case can only input values and got results all 'outside' calling the tested function. I mean, like..

void TestSuite_copy0716_c_ac302433_TestCase1()
{
parameter [0u] = CPPTEST_DS_GET_INTEGER("[IN].CurrBuff_0");
testedfunction(&parameter);
expectedResult = CPPTEST_DS_GET_INTEGER("[IN].Result");
experimentResult = parameter[0];
CPPTEST_ASSERT_INTEGER_EQUAL(expectedResult, experimentResult);
}

But what I want is to check the value of parameter[0] in one of sections inside tested function.

Could anyone provide me a hint or some comments?
Thanks a lot in advance!

Answers

  • Mirek
    Mirek Posts: 141 admin

    Hi @lintu,

    I'm not sure if I get it right, please confirm that my understanding of the problem is correct:

    you have a test case:

    void TestSuite_copy0716_c_ac302433_TestCase1()
    {
    parameter [0u] = CPPTEST_DS_GET_INTEGER("[IN].CurrBuff_0");
    testedfunction(&parameter);
    expectedResult = CPPTEST_DS_GET_INTEGER("[IN].Result");
    experimentResult = parameter[0];
    CPPTEST_ASSERT_INTEGER_EQUAL(expectedResult, experimentResult);
    }

    and the tested function supposedly looks like:

    Type testedFunc(Type (*parameter)[])
    {
    *parameter[0] = 33; //POINT 1
    // some code
    *parameter[0] = some_computation(); //POINT 2
    return *parameter[0];
    }

    Your intention is to be able to check the values in "parameter" at different POINTS in the tested function?