Created
February 13, 2013 08:53
-
-
Save anonymous/4943175 to your computer and use it in GitHub Desktop.
Simple example of boost::unit_test
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "add.hpp" | |
long add(long x, long y) | |
{ | |
return x + y; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifndef _TEST_TEST_ADD_HPP | |
#define _TEST_TEST_ADD_HPP | |
long add(long x, long y); | |
#endif |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "add.hpp" | |
#define BOOST_TEST_MAIN | |
#include <boost/test/unit_test.hpp> | |
BOOST_AUTO_TEST_CASE( a_add_test ) | |
{ | |
BOOST_CHECK( add( 2, 2 ) == 4 ); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
g++ -o add_test -I${BOOST}/include add_test.cpp add.cpp -L${BOOST}/lib/ -lboost_unit_test_framework -static |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment