В моем файле core.h
Код: Выделить всё
int globalMethod(bool flag);
Код: Выделить всё
#include "core.h"
bool globalVar = false;
int globalMethod(bool flag) {
if(flag)
{
globalVar = true;
return true;
}
return false;
}
Код: Выделить всё
#include
#include
#include
BOOST_AUTO_TEST_SUITE(ourextns)
BOOST_AUTO_TEST_SUITE(myextns)
BOOST_AUTO_TEST_CASE(case1)
{
globalMethod(true);
bool result = myFirstMethod(); // does not fail because globalVar is true
BOOST_REQUIRE(result);
}
BOOST_AUTO_TEST_CASE(case2)
{
someother_api_method(); // internally CHECKS globalVar is true or not and finds true!!
bool result = mySecondMethod(); // !!succeeds as the method before this succeeded - it should fail
BOOST_REQUIRE(result); // success
}
BOOST_AUTO_TEST_SUITE_END()
BOOST_AUTO_TEST_SUITE_END()
Подробнее здесь: https://stackoverflow.com/questions/786 ... s-once-set