Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using boost test with Visual Studio

I am trying to use Boost Test to add some much needed unit tests to my code. However I can't seem to get it to work. Right now I have the following code

#include <Drawing.h>
#define BOOST_AUTO_TEST_MAIN
#define BOOST_TEST_MODULE DrawingModelTests
#include <boost/test/unit_test.hpp>

BOOST_AUTO_TEST_SUITE(DrawingModelTests)

BOOST_AUTO_TEST_CASE ( DrawingConstructorTest)
{
    Drawing * drawing = new Drawing;

    delete drawing;
}

BOOST_AUTO_TEST_SUITE_END()

From what I understand I don't need to put a main or anything since boost will take care of it himself. However Visual Studio keep giving me a "entry point must be defined" error. Do I need to manually add a link to the static library or something? I am compiling as a standard .exe console application.

like image 980
Laurent Bourgault-Roy Avatar asked Jan 15 '10 03:01

Laurent Bourgault-Roy


People also ask

How do I run a test in Visual Studio?

To run all the tests in a default group, choose the Run icon and then choose the group on the menu. Select the individual tests that you want to run, open the right-click menu for a selected test and then choose Run Selected Tests (or press Ctrl + R, T).

How do I use Google tests in Visual Studio?

Add a Google Test project in Visual Studio 2022In Solution Explorer, right-click on the solution node and choose Add > New Project. Set Language to C++ and type test in the search box. From the results list, choose Google Test Project. Give the test project a name and choose OK.

How do I use Windows Boost?

Install Boost (Windows)Download the source code from http://www.boost.org/users/download/. Extract in a Boost folder located at C:\ or C:\Program files so that CMake find-modules can detect it. Invoke the command line and navigate to the extracted folder (e.g. cd C:\Boost\boost_1_63_0 ).

How do I link my boost library to Windows?

6.1 Link From Within the Visual Studio IDEIn Configuration Properties > Linker > Additional Library Directories, enter the path to the Boost binaries, e.g. C:\Program Files\boost\boost_1_55_0\lib\. From the Build menu, select Build Solution.


1 Answers

Add /SUBSYSTEM:CONSOLE to the linker flags. In the project settings, this is on the Linker->System page. You can use boost as either dynamic or static library.

like image 184
Khouri Giordano Avatar answered Sep 29 '22 16:09

Khouri Giordano