Boost logo

Boost-Commit :

From: ramey_at_[hidden]
Date: 2008-04-06 16:04:20


Author: ramey
Date: 2008-04-06 16:04:20 EDT (Sun, 06 Apr 2008)
New Revision: 44082
URL: http://svn.boost.org/trac/boost/changeset/44082

Log:
enhanced test to detect more errors
Text files modified:
   trunk/libs/serialization/test/test_static_warning.cpp | 32 ++++++++++++++++++++++++++------
   1 files changed, 26 insertions(+), 6 deletions(-)

Modified: trunk/libs/serialization/test/test_static_warning.cpp
==============================================================================
--- trunk/libs/serialization/test/test_static_warning.cpp (original)
+++ trunk/libs/serialization/test/test_static_warning.cpp 2008-04-06 16:04:20 EDT (Sun, 06 Apr 2008)
@@ -7,6 +7,7 @@
 
 // note: this is a compile only test.
 
+#include <boost/config.hpp> // BOOST_STATIC_CONST
 #include <boost/static_warning.hpp>
 #include <boost/type_traits/is_polymorphic.hpp>
 
@@ -22,23 +23,42 @@
 class non_polymorphic {
 };
 
-// note: compilation of this program should show 8 warning messages
+class test_class {
+};
+
+template <class T>
+int f()
+{
+ BOOST_STATIC_WARNING(T::value);
+ return 0;
+}
+
+struct A {
+ BOOST_STATIC_CONSTANT(bool, value = 0);
+};
+
+/////////////////////////////////////////////////////////////////////////
+// compilation of this program should show a total of 10 warning messages
 
+// should show NO warning message
 BOOST_STATIC_WARNING(true);
+
+// the following should show 5 warning message
+int x = f<A>();
 BOOST_STATIC_WARNING(sizeof(a1) == sizeof(a2)); // Warn.
 BOOST_STATIC_WARNING(sizeof(a1) != sizeof(a1)); // Warn.
 BOOST_STATIC_WARNING(! boost::is_polymorphic<polymorphic>::value); // Warn.
 BOOST_STATIC_WARNING(boost::is_polymorphic<non_polymorphic>::value); // Warn.
 
-void warnings() {
+int main(int /* argc */, char * /* argv */[]){
+ // should show NO warning message
     BOOST_STATIC_WARNING(true);
+
+ // the following should show 5 warning message
+ f<A>();
     BOOST_STATIC_WARNING(sizeof(a1) == sizeof(a2)); // Warn.
     BOOST_STATIC_WARNING(sizeof(a1) != sizeof(a1)); // Warn.
     BOOST_STATIC_WARNING(! boost::is_polymorphic<polymorphic>::value); // Warn.
     BOOST_STATIC_WARNING(boost::is_polymorphic<non_polymorphic>::value); // Warn.
-}
-
-int main(int /* argc */, char * /* argv */[]){
- warnings();
     return 0;
 }


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk