$include_dir="/home/hyper-archives/boost-users/include"; include("$include_dir/msg-header.inc") ?>
From: Andrew n marshall (amarshal_at_[hidden])
Date: 2005-12-10 22:55:20
I've encountered a problem when transitioning from Boost.Test 1.32 to
1.33. New to 1.33 is a set_precision(..) method on the print_log_value
functor (in test_tools.hpp). The problem, as I see it, is the use of
numeric_limits<T>, which exposes the assumption T is a numeric entity at
all. I'm actually surprised it compiles as often as it does, so maybe
my blame is misdirected. Nonetheless, I was able to create the attached
test case to prove my point. I've also included the generated build log
with the really nasty compile time error.
Anm
// Weird Compile problem with Boost.Test 1.33
#include <iostream>
#include <boost/test/unit_test.hpp>
using boost::unit_test::test_suite;
// Class heirarchy and support functions
class Abstract {
virtual void go() = 0; // If Abstract is not pure virtual, everything compiles fine
};
class Concrete : public Abstract {
virtual void go() { }
};
inline bool operator== ( const Abstract& a, const Abstract& b ) {
return &a == &b; // identity
}
template <class C, class T > // character type, traits
inline std::basic_ostream<C,T>& operator<< ( std::basic_ostream<C,T>& out, const Abstract& a ) {
// Just prints a memory address.
return out << "Abstract_at_0x" << &a;
}
// Function that forces us to work with the abstract interface
Abstract& generalize( Concrete& c ) {
return c;
}
// Test case & suite
void test_abstract_identity() {
Concrete a, b;
// These work
BOOST_CHECK_EQUAL( a, a ); // works
BOOST_CHECK_EQUAL( a, b ); // fails correctly
// These won't compile with 1.33 & VC++7.1
BOOST_CHECK_EQUAL( generalize(a), a );
Abstract& c = a;
BOOST_CHECK_EQUAL( a, c );
}
test_suite*
init_unit_test_suite( int, char* [] ) {
test_suite* test= BOOST_TEST_SUITE( "Example failure of Boost.Test 1.33.0" );
test->add( BOOST_TEST_CASE( &test_abstract_identity ), 1 );
return test;
}
// EOF
| Build Log |
|
| Command Lines |
Creating temporary file "d:\Projects\Saso\sandbox\saso\core\smartbody\motionengine\visualc7-boost1_33\obj\Boost.Test-test_debug\RSP000018.rsp" with contents [ /Od /I "..\include\\" /I "D:\local\lib\boost_1_33_0" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "BOOST_TEST_NO_AUTO_LINK" /D "_MBCS" /Gm /EHsc /RTC1 /MDd /GS /Fo".\obj\Boost.Test-test_debug/" /Fd".\obj\Boost.Test-test_debug/vc70.pdb" /W3 /c /Wp64 /ZI /TP "\Projects\Saso\sandbox\saso\core\smartbody\motionengine\src\test\BoostTest-test.cpp" ] Creating command line "cl.exe @"d:\Projects\Saso\sandbox\saso\core\smartbody\motionengine\visualc7-boost1_33\obj\Boost.Test-test_debug\RSP000018.rsp" /nologo" |
| Output Window |
Compiling...
BoostTest-test.cpp
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include\limits(75) : error C2259: 'Abstract' : cannot instantiate abstract class
due to following members:
'void Abstract::go(void)' : pure virtual function was not defined
d:\Projects\SASO\sandbox\saso\core\smartbody\motionengine\src\test\BoostTest-test.cpp(10) : see declaration of 'Abstract::go'
d:\local\lib\boost_1_33_0\boost\test\test_tools.hpp(279) : see reference to class template instantiation 'std::numeric_limits<_Ty>' being compiled
with
[
_Ty=Abstract
]
d:\local\lib\boost_1_33_0\boost\test\test_tools.hpp(278) : while compiling class-template member function 'void boost::test_tools::tt_detail::print_log_value |
| Results |
Build log was saved at "file://d:\Projects\Saso\sandbox\saso\core\smartbody\motionengine\visualc7-boost1_33\obj\Boost.Test-test_debug\BuildLog.htm" Boost.Test-test - 8 error(s), 0 warning(s) |