Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r79766 - trunk/libs/xpressive/test
From: eric_at_[hidden]
Date: 2012-07-27 00:59:57


Author: eric_niebler
Date: 2012-07-27 00:59:56 EDT (Fri, 27 Jul 2012)
New Revision: 79766
URL: http://svn.boost.org/trac/boost/changeset/79766

Log:
make regress and c_traits tests smaller by factoring out wide-char tests
Added:
   trunk/libs/xpressive/test/c_traits_u.cpp (contents, props changed)
   trunk/libs/xpressive/test/regress_u.cpp (contents, props changed)
Text files modified:
   trunk/libs/xpressive/test/Jamfile.v2 | 2 ++
   trunk/libs/xpressive/test/regress.ipp | 34 +++++++++++-----------------------
   2 files changed, 13 insertions(+), 23 deletions(-)

Modified: trunk/libs/xpressive/test/Jamfile.v2
==============================================================================
--- trunk/libs/xpressive/test/Jamfile.v2 (original)
+++ trunk/libs/xpressive/test/Jamfile.v2 2012-07-27 00:59:56 EDT (Fri, 27 Jul 2012)
@@ -25,7 +25,9 @@
 
 test-suite "xpressive"
        : [ run regress.cpp : : : <toolset>msvc:<cxxflags>/bigobj <dependency>regress.txt ]
+ [ run regress_u.cpp : : : <toolset>msvc:<cxxflags>/bigobj <dependency>regress.txt ]
          [ run c_traits.cpp : : : <toolset>msvc:<cxxflags>/bigobj <dependency>regress.txt ]
+ [ run c_traits_u.cpp : : : <toolset>msvc:<cxxflags>/bigobj <dependency>regress.txt ]
          [ run test1.cpp ]
          [ run test2.cpp ]
          [ run test3.cpp ]

Added: trunk/libs/xpressive/test/c_traits_u.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/xpressive/test/c_traits_u.cpp 2012-07-27 00:59:56 EDT (Fri, 27 Jul 2012)
@@ -0,0 +1,17 @@
+//////////////////////////////////////////////////////////////////////////////
+// c_traits.cpp
+//
+// (C) Copyright Eric Niebler 2004.
+// Use, modification and distribution are subject to 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)
+
+/*
+ Revision history:
+ 6 January 2006 : Initial version.
+*/
+
+#define BOOST_XPRESSIVE_USE_C_TRAITS
+#define BOOST_XPRESSIVE_TEST_WREGEX
+#include "./regress.ipp"
+

Modified: trunk/libs/xpressive/test/regress.ipp
==============================================================================
--- trunk/libs/xpressive/test/regress.ipp (original)
+++ trunk/libs/xpressive/test/regress.ipp 2012-07-27 00:59:56 EDT (Fri, 27 Jul 2012)
@@ -25,13 +25,13 @@
 # include <crtdbg.h>
 #endif
 
-#ifndef BOOST_XPRESSIVE_NO_WREGEX
+#if defined(BOOST_XPRESSIVE_TEST_WREGEX) && !defined(BOOST_XPRESSIVE_NO_WREGEX)
 namespace std
 {
     inline std::ostream &operator <<(std::ostream &sout, std::wstring const &wstr)
     {
         for(std::size_t n = 0; n < wstr.size(); ++n)
- sout.put(sout.narrow(wstr[n], '?'));
+ sout.put(BOOST_USE_FACET(std::ctype<wchar_t>, std::locale()).narrow(wstr[n], '?'));
         return sout;
     }
 }
@@ -95,7 +95,7 @@
 
 test_case_formatter const case_ = {};
 
-#ifndef BOOST_XPRESSIVE_NO_WREGEX
+#if defined(BOOST_XPRESSIVE_TEST_WREGEX) && !defined(BOOST_XPRESSIVE_NO_WREGEX)
 ///////////////////////////////////////////////////////////////////////////////
 // widen
 // make a std::wstring from a std::string by widening according to the
@@ -316,7 +316,7 @@
 
                 for(std::size_t i = 0; i < br.size() && i < test.br.size(); ++i)
                 {
- BOOST_XPR_CHECK(!br[i].matched && test.br[i] == empty || test.br[i] == br[i].str());
+ BOOST_XPR_CHECK((!br[i].matched && test.br[i] == empty) || test.br[i] == br[i].str());
                 }
             }
 
@@ -355,7 +355,7 @@
 
                 for(std::size_t i = 0; i < what.size() && i < test.br.size(); ++i)
                 {
- BOOST_XPR_CHECK(!what[i].matched && test.br[i] == empty || test.br[i] == what[i].str());
+ BOOST_XPR_CHECK((!what[i].matched && test.br[i] == empty) || test.br[i] == what[i].str());
                 }
             }
             else
@@ -374,31 +374,17 @@
 ///////////////////////////////////////////////////////////////////////////////
 // run_test_impl
 // run the current test
-void run_test_a()
-{
- run_test_impl(test);
-}
-
-///////////////////////////////////////////////////////////////////////////////
-// run_test_u
-// widen the current test and run it
-void run_test_u()
+void run_test()
 {
- #ifndef BOOST_XPRESSIVE_NO_WREGEX
+ #ifdef BOOST_XPRESSIVE_TEST_WREGEX
     xpr_test_case<wchar_t> wtest = ::widen(test);
     run_test_impl(wtest);
+ #else
+ run_test_impl(test);
     #endif
 }
 
 ///////////////////////////////////////////////////////////////////////////////
-// run_test
-void run_test()
-{
- run_test_a();
- run_test_u();
-}
-
-///////////////////////////////////////////////////////////////////////////////
 // open_test
 bool open_test()
 {
@@ -425,6 +411,7 @@
 // read the tests from the input file and execute them
 void test_main()
 {
+ #if !defined(BOOST_XPRESSIVE_TEST_WREGEX) || !defined(BOOST_XPRESSIVE_NO_WREGEX)
     if(!open_test())
     {
         BOOST_ERROR("Error: unable to open input file.");
@@ -435,6 +422,7 @@
         run_test();
         ++test_count;
     }
+ #endif
 
     std::cout << test_count << " tests completed." << std::endl;
 }

Added: trunk/libs/xpressive/test/regress_u.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/xpressive/test/regress_u.cpp 2012-07-27 00:59:56 EDT (Fri, 27 Jul 2012)
@@ -0,0 +1,15 @@
+//////////////////////////////////////////////////////////////////////////////
+// regress_u.cpp
+//
+// (C) Copyright Eric Niebler 2004.
+// Use, modification and distribution are subject to 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)
+
+/*
+ Revision history:
+ 6 January 2006 : Initial version.
+*/
+
+#define BOOST_XPRESSIVE_TEST_WREGEX
+#include "./regress.ipp"


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