|
Boost : |
From: John Maddock (john_at_[hidden])
Date: 2006-10-18 05:00:45
Joaquin M Lopez Munoz wrote:
> Let me try my hand at it first, I think I'll be able to make
> it work in a few days.
Thanks Joaquin: in the mean time you might like to know that most of the
currect errors are down to problems with using declarations and those
compilers, here are my current patches that I think gets everything except
those non-member operators working.
John.
Index: libs/rational/rational_test.cpp
===================================================================
RCS file: /cvsroot/boost/boost/libs/rational/rational_test.cpp,v
retrieving revision 1.19
diff -u -r1.19 rational_test.cpp
--- libs/rational/rational_test.cpp 5 Jan 2006 13:31:24 -0000 1.19
+++ libs/rational/rational_test.cpp 18 Oct 2006 08:53:48 -0000
@@ -164,41 +164,37 @@
// GCD tests
BOOST_AUTO_TEST_CASE_TEMPLATE( gcd_test, T, all_signed_test_types )
{
- using boost::gcd;
-
- BOOST_CHECK_EQUAL( gcd<T>( 1, -1), static_cast<T>( 1) );
- BOOST_CHECK_EQUAL( gcd<T>( -1, 1), static_cast<T>( 1) );
- BOOST_CHECK_EQUAL( gcd<T>( 1, 1), static_cast<T>( 1) );
- BOOST_CHECK_EQUAL( gcd<T>( -1, -1), static_cast<T>( 1) );
- BOOST_CHECK_EQUAL( gcd<T>( 0, 0), static_cast<T>( 0) );
- BOOST_CHECK_EQUAL( gcd<T>( 7, 0), static_cast<T>( 7) );
- BOOST_CHECK_EQUAL( gcd<T>( 0, 9), static_cast<T>( 9) );
- BOOST_CHECK_EQUAL( gcd<T>( -7, 0), static_cast<T>( 7) );
- BOOST_CHECK_EQUAL( gcd<T>( 0, -9), static_cast<T>( 9) );
- BOOST_CHECK_EQUAL( gcd<T>( 42, 30), static_cast<T>( 6) );
- BOOST_CHECK_EQUAL( gcd<T>( 6, -9), static_cast<T>( 3) );
- BOOST_CHECK_EQUAL( gcd<T>(-10, -10), static_cast<T>(10) );
- BOOST_CHECK_EQUAL( gcd<T>(-25, -10), static_cast<T>( 5) );
+ BOOST_CHECK_EQUAL( boost::gcd<T>( 1, -1), static_cast<T>( 1) );
+ BOOST_CHECK_EQUAL( boost::gcd<T>( -1, 1), static_cast<T>( 1) );
+ BOOST_CHECK_EQUAL( boost::gcd<T>( 1, 1), static_cast<T>( 1) );
+ BOOST_CHECK_EQUAL( boost::gcd<T>( -1, -1), static_cast<T>( 1) );
+ BOOST_CHECK_EQUAL( boost::gcd<T>( 0, 0), static_cast<T>( 0) );
+ BOOST_CHECK_EQUAL( boost::gcd<T>( 7, 0), static_cast<T>( 7) );
+ BOOST_CHECK_EQUAL( boost::gcd<T>( 0, 9), static_cast<T>( 9) );
+ BOOST_CHECK_EQUAL( boost::gcd<T>( -7, 0), static_cast<T>( 7) );
+ BOOST_CHECK_EQUAL( boost::gcd<T>( 0, -9), static_cast<T>( 9) );
+ BOOST_CHECK_EQUAL( boost::gcd<T>( 42, 30), static_cast<T>( 6) );
+ BOOST_CHECK_EQUAL( boost::gcd<T>( 6, -9), static_cast<T>( 3) );
+ BOOST_CHECK_EQUAL( boost::gcd<T>(-10, -10), static_cast<T>(10) );
+ BOOST_CHECK_EQUAL( boost::gcd<T>(-25, -10), static_cast<T>( 5) );
}
// LCM tests
BOOST_AUTO_TEST_CASE_TEMPLATE( lcm_test, T, all_signed_test_types )
{
- using boost::lcm;
-
- BOOST_CHECK_EQUAL( lcm<T>( 1, -1), static_cast<T>( 1) );
- BOOST_CHECK_EQUAL( lcm<T>( -1, 1), static_cast<T>( 1) );
- BOOST_CHECK_EQUAL( lcm<T>( 1, 1), static_cast<T>( 1) );
- BOOST_CHECK_EQUAL( lcm<T>( -1, -1), static_cast<T>( 1) );
- BOOST_CHECK_EQUAL( lcm<T>( 0, 0), static_cast<T>( 0) );
- BOOST_CHECK_EQUAL( lcm<T>( 6, 0), static_cast<T>( 0) );
- BOOST_CHECK_EQUAL( lcm<T>( 0, 7), static_cast<T>( 0) );
- BOOST_CHECK_EQUAL( lcm<T>( -5, 0), static_cast<T>( 0) );
- BOOST_CHECK_EQUAL( lcm<T>( 0, -4), static_cast<T>( 0) );
- BOOST_CHECK_EQUAL( lcm<T>( 18, 30), static_cast<T>(90) );
- BOOST_CHECK_EQUAL( lcm<T>( -6, 9), static_cast<T>(18) );
- BOOST_CHECK_EQUAL( lcm<T>(-10, -10), static_cast<T>(10) );
- BOOST_CHECK_EQUAL( lcm<T>( 25, -10), static_cast<T>(50) );
+ BOOST_CHECK_EQUAL( boost::lcm<T>( 1, -1), static_cast<T>( 1) );
+ BOOST_CHECK_EQUAL( boost::lcm<T>( -1, 1), static_cast<T>( 1) );
+ BOOST_CHECK_EQUAL( boost::lcm<T>( 1, 1), static_cast<T>( 1) );
+ BOOST_CHECK_EQUAL( boost::lcm<T>( -1, -1), static_cast<T>( 1) );
+ BOOST_CHECK_EQUAL( boost::lcm<T>( 0, 0), static_cast<T>( 0) );
+ BOOST_CHECK_EQUAL( boost::lcm<T>( 6, 0), static_cast<T>( 0) );
+ BOOST_CHECK_EQUAL( boost::lcm<T>( 0, 7), static_cast<T>( 0) );
+ BOOST_CHECK_EQUAL( boost::lcm<T>( -5, 0), static_cast<T>( 0) );
+ BOOST_CHECK_EQUAL( boost::lcm<T>( 0, -4), static_cast<T>( 0) );
+ BOOST_CHECK_EQUAL( boost::lcm<T>( 18, 30), static_cast<T>(90) );
+ BOOST_CHECK_EQUAL( boost::lcm<T>( -6, 9), static_cast<T>(18) );
+ BOOST_CHECK_EQUAL( boost::lcm<T>(-10, -10), static_cast<T>(10) );
+ BOOST_CHECK_EQUAL( boost::lcm<T>( 25, -10), static_cast<T>(50) );
}
BOOST_AUTO_TEST_SUITE_END()
@@ -569,17 +565,15 @@
// Conversion test
BOOST_AUTO_TEST_CASE( rational_cast_test )
{
- using boost::rational_cast;
-
// Note that these are not generic. The problem is that
rational_cast<T>
// requires a conversion from IntType to T. However, for a
user-defined
// IntType, it is not possible to define such a conversion except as an
// "operator T()". This causes problems with overloading resolution.
boost::rational<int> const half( 1, 2 );
- BOOST_CHECK_CLOSE( rational_cast<double>(half), 0.5, 0.01 );
- BOOST_CHECK_EQUAL( rational_cast<int>(half), 0 );
- BOOST_CHECK_EQUAL( rational_cast<MyInt>(half), MyInt() );
+ BOOST_CHECK_CLOSE( boost::rational_cast<double>(half), 0.5, 0.01 );
+ BOOST_CHECK_EQUAL( boost::rational_cast<int>(half), 0 );
+ BOOST_CHECK_EQUAL( boost::rational_cast<MyInt>(half), MyInt() );
}
// Dice tests (a non-main test)
diff -u -r1.16 rational.hpp
--- boost/rational.hpp 27 Dec 2005 11:38:27 -0000 1.16
+++ boost/rational.hpp 18 Oct 2006 08:55:54 -0000
@@ -508,7 +508,7 @@
// Type conversion
template <typename T, typename IntType>
-inline T rational_cast(const rational<IntType>& src)
+inline T rational_cast(const rational<IntType>& src
BOOST_APPEND_EXPLICIT_TEMPL
ATE_TYPE(T))
{
return static_cast<T>(src.numerator())/src.denominator();
}
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk