Skip to content

int test_function()

CountrySideEngineer edited this page Dec 3, 2022 · 1 revision

int test_function()

This page describes the test driver code to test the method like int test_function().
(A method with return value and no argument.)

test driver code.

The test driver code in source file is like below:

TEST_F(test_function, test_function_001)
{
    int _ret_val;

    /*
     * Set stub output values if the test_function() has sub function.
     */

    int _ret_val = test_function();    // Call test target function.

    ASSET_EQ(expected_value, _ret_val);
    /*
     * Check the result of target function execution with "ASSERT_EQ" macro of googletest.
     */
}

The _ret_val is a variable to set the value the test function returned, its name is fixed and can not change it.
The expected_value in above code will be replaced by a value designed.