Update of /cvsroot/boost/boost/libs/test/example
In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv1173
Modified Files:
Tag: RC_1_34_0
unit_test_example_01.cpp
Log Message:
Merged garbage removeal from trunk to branch
Index: unit_test_example_01.cpp
===================================================================
RCS file: /cvsroot/boost/boost/libs/test/example/unit_test_example_01.cpp,v
retrieving revision 1.2
retrieving revision 1.2.2.1
diff -u -d -r1.2 -r1.2.2.1
--- unit_test_example_01.cpp 19 Mar 2006 12:01:47 -0000 1.2
+++ unit_test_example_01.cpp 23 Feb 2007 18:20:10 -0000 1.2.2.1
@@ -1,52 +1,39 @@
-#include <iostream>
+// (C) Copyright Gennadiy Rozental 2005.
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
-namespace ieee_754 {
+// See http://www.boost.org/libs/test for the library home page.
-template<typename T>
-struct decoded {
- typedef long long mantissa_holder_type;
- typedef short exponent_holder_type;
+// Boost.Test
- bool p_sign;
- mantissa_holder_type p_mantissa;
- exponent_holder_type p_exponent;
-};
+// each test module could contain no more then one 'main' file with init
function defined
+// alternatively you could define init function yourself
+#define BOOST_TEST_MAIN
+#include <boost/test/unit_test.hpp>
-//___________________________________________________________________________//
+//____________________________________________________________________________//
-void decode( double v, decoded<double>& d )
+// most frequently you implement test cases as a free functions with automatic
registration
+BOOST_AUTO_TEST_CASE( test1 )
{
- union {
- double v;
- long long m;
- } tmp;
-
- tmp.v = v;
-
- d.p_sign = !(tmp.m & 0x8000000000000000LL);
- d.p_mantissa = tmp.m & 0x000FFFFFFFFFFFFFLL;
- d.p_exponent = (short)((tmp.m & 0x7FF0000000000000LL) >> 52) - 1075;
-
- if( d.p_exponent != 0 )
- d.p_mantissa |= 0x0010000000000000LL;
+ // reports 'error in "test1": test 2 == 1 failed'
+ BOOST_CHECK( 2 == 1 );
}
-//___________________________________________________________________________//
-
-} // namespace ieee_754
-
-using namespace ieee_754;
+//____________________________________________________________________________//
-int
-main()
+// each test file may contain any number of test cases; each test case has to
have unique name
+BOOST_AUTO_TEST_CASE( test2 )
{
- double d = 0.2;
- decoded<double> dec;
+ int i = 0;
- decode( d, dec );
+ // reports 'error in "test2": check i == 2 failed [0 != 2]'
+ BOOST_CHECK_EQUAL( i, 2 );
- std::cout << "orig = " << std::hex << *(long long*)&d <<
std::endl;
- std::cout << "dec.p_sign = " << (dec.p_sign ? '+' : '-') << std::endl;
- std::cout << "dec.p_mantissa = " << std::hex << dec.p_mantissa <<
std::endl;
- std::cout << "dec.p_exponent = " << std::dec << dec.p_exponent <<
std::endl;
+ BOOST_CHECK_EQUAL( i, 0 );
}
+
+//____________________________________________________________________________//
+
+// EOF
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Boost-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/boost-cvs