S
saneman
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_module);
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_EQUAL(t,22);
}
BOOST_AUTO_TEST_CASE(test_two)
{
// do som other test
BOOST_CHECK_EQUAL(i,4);
}
BOOST_AUTO_TEST_SUITE_END();
BOOST_AUTO_TEST_CASE(my_always_fail_test_case)
{
BOOST_CHECK(false);
}
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_module);
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_EQUAL(t,22);
}
BOOST_AUTO_TEST_CASE(test_two)
{
// do som other test
BOOST_CHECK_EQUAL(i,4);
}
BOOST_AUTO_TEST_SUITE_END();
BOOST_AUTO_TEST_CASE(my_always_fail_test_case)
{
BOOST_CHECK(false);
}
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?