Project structure issue

Viewed 114

My goal is to achieve a test project on VisualStudio 2019.

I think that my main problem is with How to structure my project. Because, at the end, I find many files and don't know how to manage them.

These are the test .cpp files :

TIStream.cpp :

#include <boost/test/unit_test.hpp>
#include <boost/test/data/test_case.hpp>
#include <boost/test/data/monomorphic.hpp>
#include "../ReemasCore/serialization.h"
#include <string.h>

BOOST_AUTO_TEST_SUITE(Serialization_InMemStream)

BOOST_AUTO_TEST_CASE(InMemStreamCtor_SizePositif_CorrectPointer)
{
    auto in = std::make_unique<InMemStream>(10);

    BOOST_TEST(in->ppStart != nullptr);
    BOOST_TEST(in->ppCurrent == in->ppStart);
    BOOST_TEST(in->ppEnd == in->ppStart + 10);
}
BOOST_AUTO_TEST_SUITE_END()

TTCPServer :

#include <boost/test/unit_test.hpp>

BOOST_AUTO_TEST_SUITE(TCP_SERVER)

BOOST_AUTO_TEST_CASE(Server_Case1)
{
    BOOST_TEST(1 == 1);
    BOOST_TEST(true);
}

BOOST_AUTO_TEST_SUITE_END()
1 Answers

Based on this mailing the dynamic version of Boost Test doesn't contain the main function from version 1.34.1 and up. So if you want to use the shared version of Boost Test you need to follow the instructions from Boost Test doc.

You have to put #define BOOST_TEST_MODULE test module name before the #include <boost/test/unit_test.hpp>. As the documentation says it must be defined exactly for one compilation unit of your test module. As you create different executables for every test, then it practically means you have to put it into every test source file.

Related