I am using boost for unittesting. But I would like to make a global
container with some content that can be used in all the boost functions:
#define BOOST_AUTO_TEST _MAIN
#include <boost/test/auto_unit_test. hpp>
// Boost Test declaration and Checking macros
#include <boost/test/unit_test_suite .hpp>
#include <boost/test/test_tools.hpp>
BOOST_AUTO_TEST _SUITE(my_modul e);
BOOST_AUTO_TEST _SUITE();
// Types
std::vector<int v;
v.push_back(22) ; //This gives an error!
BOOST_AUTO_TEST _CASE(test_one)
{
int t = *v.begin()
BOOST_CHECK_EQU AL(t,22);
}
BOOST_AUTO_TEST _CASE(test_two)
{
// do som other test
BOOST_CHECK_EQU AL(i,4);
}
BOOST_AUTO_TEST _SUITE_END();
BOOST_AUTO_TEST _CASE(my_always _fail_test_case )
{
BOOST_CHECK(fal se);
}
BOOST_AUTO_TEST _SUITE_END();
But when I do v.push_back(22) ; and compile I get:
syntax error : missing ';' before '.'
error C4430: missing type specifier - int assumed. Note: C++ does not
support default-int
Is it not possible to use global data?
container with some content that can be used in all the boost functions:
#define BOOST_AUTO_TEST _MAIN
#include <boost/test/auto_unit_test. hpp>
// Boost Test declaration and Checking macros
#include <boost/test/unit_test_suite .hpp>
#include <boost/test/test_tools.hpp>
BOOST_AUTO_TEST _SUITE(my_modul e);
BOOST_AUTO_TEST _SUITE();
// Types
std::vector<int v;
v.push_back(22) ; //This gives an error!
BOOST_AUTO_TEST _CASE(test_one)
{
int t = *v.begin()
BOOST_CHECK_EQU AL(t,22);
}
BOOST_AUTO_TEST _CASE(test_two)
{
// do som other test
BOOST_CHECK_EQU AL(i,4);
}
BOOST_AUTO_TEST _SUITE_END();
BOOST_AUTO_TEST _CASE(my_always _fail_test_case )
{
BOOST_CHECK(fal se);
}
BOOST_AUTO_TEST _SUITE_END();
But when I do v.push_back(22) ; and compile I get:
syntax error : missing ';' before '.'
error C4430: missing type specifier - int assumed. Note: C++ does not
support default-int
Is it not possible to use global data?
Comment