Narzędzia użytkownika

Narzędzia witryny


boosttest

To jest stara wersja strony!


Opis biblioteki

Minimal testing facility

#include <boost/test/minimal.hpp>
#include <iostream>
 
int square_err( int arg )
{
	return arg*arg-1;		//blad gruby:)
}
 
int square( int arg )
{
	return arg*arg;
}
 
int cube( int arg )
{
	return arg*arg*arg;
}
 
int cube_err( int arg )
{
	return square_err( arg )*arg;
}
 
int test_main( int /*argc*/, char* /*argv*/[] )		//uwaga - zmieniona nazwa funkcji main
{
 
	int foo(3);
 
	BOOST_REQUIRE( foo == 3 );
 
	BOOST_CHECK( square( foo ) == 9 );
	BOOST_CHECK( square_err( foo ) == 9 );
 
	BOOST_CHECK( cube( foo ) == 27 );
	BOOST_CHECK( cube_err( foo ) == 27 );
 
	if( foo != 4 )
		BOOST_ERROR( "foo != 4 !!!!!" );
 
	//ponizsze 3 sprawdzenia przy bledzie spowoduja przerwanie dalszego testowania
 
	if(cube( foo ) != 4 )
		throw "cube(3) != 4";			//recznie wykryty blad, zglaszany poprzez wyjatek
										//ktory nie ma okazji byc zlapany
 
	if(cube( foo ) != 8 )
		BOOST_FAIL("cube(3) != 8");		//rowniez zglasza wyjatek
 
	BOOST_REQUIRE( foo == 4 );			//blad w BOOST_REQUIRE powoduje przerwanie testow
 
	std::cout << "Ten kod nigdy nie zostanie osiagniety\n";
 
    return 0;
}

Program execution monitor

Execution monitor

Unit test framework

boosttest.1208303394.txt.gz · ostatnio zmienione: 2008/04/16 01:49 przez twroniak