Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r66467 - in sandbox/chrono/libs/static_string/test: . insert match
From: vicente.botet_at_[hidden]
Date: 2010-11-09 01:33:29


Author: viboes
Date: 2010-11-09 01:33:28 EST (Tue, 09 Nov 2010)
New Revision: 66467
URL: http://svn.boost.org/trac/boost/changeset/66467

Log:
StaticString:
* Split match and insert

Added:
   sandbox/chrono/libs/static_string/test/insert/
   sandbox/chrono/libs/static_string/test/insert/insert_pass.cpp (contents, props changed)
Text files modified:
   sandbox/chrono/libs/static_string/test/Jamfile.v2 | 5 +
   sandbox/chrono/libs/static_string/test/match/match_pass.cpp | 127 +--------------------------------------
   2 files changed, 10 insertions(+), 122 deletions(-)

Modified: sandbox/chrono/libs/static_string/test/Jamfile.v2
==============================================================================
--- sandbox/chrono/libs/static_string/test/Jamfile.v2 (original)
+++ sandbox/chrono/libs/static_string/test/Jamfile.v2 2010-11-09 01:33:28 EST (Tue, 09 Nov 2010)
@@ -55,4 +55,9 @@
         [ run match/match_pass.cpp ]
         ;
 
+ test-suite "insert"
+ :
+ [ run insert/insert_pass.cpp ]
+ ;
+
         
\ No newline at end of file

Added: sandbox/chrono/libs/static_string/test/insert/insert_pass.cpp
==============================================================================
--- (empty file)
+++ sandbox/chrono/libs/static_string/test/insert/insert_pass.cpp 2010-11-09 01:33:28 EST (Tue, 09 Nov 2010)
@@ -0,0 +1,110 @@
+// Copyright 2010 Vicente J. Botet Escriba
+// Distributed under the Boost Software License, Version 1.0.
+// See http://www.boost.org/LICENSE_1_0.txt
+
+#define BOOST_MPL_LIMIT_STRING_SIZE 64
+
+#include <boost/static_string/static_string.hpp>
+#include <boost/detail/lightweight_test.hpp>
+#include <iostream>
+#include <boost/type_traits/is_same.hpp>
+#include <boost/static_assert.hpp>
+#include <boost/chrono/detail/static_assert.hpp>
+#include <boost/mpl/string.hpp>
+//#include <boost/mpl/wstring.hpp>
+#include <boost/mpl/integral_c.hpp>
+#include <boost/mpl/front.hpp>
+#include <boost/mpl/size.hpp>
+#include <boost/mpl/vector_c.hpp>
+#include <string>
+#include <cstring>
+#include <iostream>
+
+#if !defined(BOOST_NO_STATIC_ASSERT)
+#define NOTHING ""
+#endif
+
+using namespace boost;
+using namespace boost::static_string;
+int main()
+{
+ {
+ typedef basic_ptree<mpl::integral_c<char, 'a'>, mpl::int_<1> > tree;
+ typedef insert<nil, mpl::pair<str_1<'a'>::type, mpl::int_<1> > >::type btree;
+ BOOST_CHRONO_STATIC_ASSERT((boost::is_same<tree,btree>::value),
+ NOTHING, (btree));
+ }
+ {
+ using namespace boost;
+ typedef
+ basic_ptree<mpl::integral_c<char, 'a'>, mpl::int_<1>,
+ basic_ptree<mpl::integral_c<char, 'b'>, mpl::int_<2> >
+ > tree;
+ typedef
+ insert<
+ insert<nil, mpl::pair<str_1<'a'>::type, mpl::int_<1> > >::type,
+ mpl::pair<str_2<'a', 'b'>::type, mpl::int_<2> >
+ >::type
+ btree;
+ BOOST_CHRONO_STATIC_ASSERT((boost::is_same<tree,btree>::value),
+ NOTHING, (insert<
+ insert<nil, mpl::pair<str_1<'a'>::type, mpl::int_<1> > >::type,
+ mpl::pair<str_2<'a', 'b'>::type, mpl::int_<2> >
+ >::type));
+ }
+ {
+ typedef
+ basic_ptree<mpl::integral_c<char, 'a'>, mpl::int_<1>,
+ basic_ptree<mpl::integral_c<char, 'b'>, mpl::int_<2>
+ >
+ > tree;
+ typedef
+ insert<
+ insert<nil, mpl::pair<str_2<'a', 'b'>::type, mpl::int_<2> > >::type,
+ mpl::pair<str_1<'a'>::type, mpl::int_<1> >
+ >::type
+ btree;
+ BOOST_CHRONO_STATIC_ASSERT((boost::is_same<tree,btree>::value),
+ NOTHING, (insert<
+ insert<nil, mpl::pair<str_2<'a', 'b'>::type, mpl::int_<2> > >::type,
+ mpl::pair<str_1<'a'>::type, mpl::int_<1> >
+ >::type));
+ }
+ {
+ typedef
+ forest<
+ basic_ptree<mpl::integral_c<char, 'a'>, mpl::int_<1> >,
+ basic_ptree<mpl::integral_c<char, 'b'>, mpl::int_<2> >
+ > tree;
+ typedef
+ insert<
+ insert<nil, mpl::pair<str_1<'a'>::type, mpl::int_<1> > >::type,
+ mpl::pair<str_1<'b'>::type, mpl::int_<2> >
+ >::type
+ btree;
+ BOOST_CHRONO_STATIC_ASSERT((boost::is_same<tree,btree>::value),
+ NOTHING, (btree));
+ }
+ {
+ typedef
+ forest<
+ basic_ptree<mpl::integral_c<char, 'a'>, mpl::int_<-1>,
+ basic_ptree<mpl::integral_c<char, 'b'>, mpl::int_<1> >
+ >,
+ basic_ptree<mpl::integral_c<char, 'b'>, mpl::int_<2> >
+ > tree;
+ typedef
+ insert<
+ insert<nil, mpl::pair<str_2<'a', 'b'>::type, mpl::int_<1> > >::type,
+ mpl::pair<str_1<'b'>::type, mpl::int_<2> >
+ >::type btree;
+
+ BOOST_CHRONO_STATIC_ASSERT((boost::is_same<tree,btree>::value),
+ NOTHING, (insert<
+ insert<nil, mpl::pair<str_2<'a', 'b'>::type, mpl::int_<1> > >::type,
+ mpl::pair<str_1<'b'>::type, mpl::int_<2> >
+ >::type));
+ }
+ return boost::report_errors();
+}
+

Modified: sandbox/chrono/libs/static_string/test/match/match_pass.cpp
==============================================================================
--- sandbox/chrono/libs/static_string/test/match/match_pass.cpp (original)
+++ sandbox/chrono/libs/static_string/test/match/match_pass.cpp 2010-11-09 01:33:28 EST (Tue, 09 Nov 2010)
@@ -27,81 +27,7 @@
 using namespace boost::static_string;
 int main()
 {
-#if 0
- {
- using namespace boost;
- typedef mpl::string<'hell','o wo','rld'> hello;
-// typedef mpl::string<'h','e','l','l','o',' ','w','o','r','l','d'> hello3;
- typedef mpl::push_back<hello, mpl::char_<'!'> >::type hello2;
- BOOST_CHRONO_STATIC_ASSERT((boost::is_same<hello::value_type,char>::value),
- NOTHING, (hello::value_type));
- std::cout << mpl::size<hello>::type::value << std::endl;
- BOOST_TEST((mpl::size<hello>::type::value == 11));
- std::cout << mpl::front<hello>::type::value << std::endl;
- std::cout << int('h') << std::endl;
- BOOST_TEST((mpl::front<hello>::type::value == 'h'));
- BOOST_TEST((std::string(mpl::c_str<hello2>::value)== "hello world!"));
 
- }
- {
- using namespace boost;
-// typedef mpl::vector_c<char, 'a','b','c','d','e'> rgc;
-// BOOST_TEST(0 == std::strcmp("abcde", static_string::c_str<rgc>::value));
-// typedef mpl::push_back<rgc, mpl::char_<'!'> >::type rgc2;
-// BOOST_TEST((std::string(static_string::c_str<rgc2>::value)== "abcde!"));
-
- typedef mpl::vector_c<char, 'h','e','l','l','o',' ','w','o','r','l','d'> hello;
- BOOST_CHRONO_STATIC_ASSERT((boost::is_same<hello::value_type,char>::value),
- NOTHING, (hello::value_type));
-// std::cout << mpl::size<hello>::type::value << std::endl;
-// BOOST_TEST((mpl::size<hello>::type::value == 11));
-// std::cout << mpl::front<hello>::type::value << std::endl;
-// std::cout << 'h' << std::endl;
-// BOOST_TEST((mpl::front<hello>::type::value == 'h'));
-// BOOST_TEST((std::string(static_string::c_str<hello>::value)== "hello world"));
- typedef mpl::push_back<hello, mpl::char_<'!'> >::type hello2;
- BOOST_CHRONO_STATIC_ASSERT((boost::is_same<static_string::value_type<hello2>::type,char>::value),
- NOTHING, (static_string::value_type<hello2>::type));
- BOOST_TEST((std::string(static_string::c_str<hello2>::value)== "hello world!"));
- }
-
-#ifndef BOOST_NO_STD_WSTRING
-#if 0
- {
- using namespace boost;
- //typedef mpl::wstring<L'hell',L'o wo',L'rld'> hello;
-// typedef mpl::wstring<L'he',L'll',L'o ',L'wo',L'rl', L'd'> hello;
- typedef mpl::wstring<L'h',L'e',L'l',L'l',L'o',L' ',L'w',L'o',L'r',L'l',L'd'> hello;
- BOOST_CHRONO_STATIC_ASSERT((boost::is_same<hello::value_type,wchar_t>::value),
- NOTHING, (hello::value_type));
- std::cout << mpl::size<hello>::type::value << std::endl;
- BOOST_TEST((mpl::size<hello>::type::value == 11));
- std::cout << mpl::front<hello>::type::value << std::endl;
- std::cout << L'h' << std::endl;
- BOOST_TEST((mpl::front<hello>::type::value == L'h'));
- BOOST_TEST((std::wstring(mpl::c_str<hello>::value)== L"hello world"));
- typedef mpl::push_back<hello, mpl::wchar_t_<L'!'> >::type hello2;
- BOOST_TEST((std::wstring(mpl::c_str<hello2>::value)== L"hello world!"));
- }
-#endif
- {
- using namespace boost;
- typedef mpl::vector_c<wchar_t, L'h',L'e',L'l',L'l',L'o',L' ',L'w',L'o',L'r',L'l',L'd'> hello;
- BOOST_CHRONO_STATIC_ASSERT((boost::is_same<hello::value_type,wchar_t>::value),
- NOTHING, (hello::value_type));
- std::cout << mpl::size<hello>::type::value << std::endl;
- BOOST_TEST((mpl::size<hello>::type::value == 11));
- std::cout << mpl::front<hello>::type::value << std::endl;
- std::cout << L'h' << std::endl;
- BOOST_TEST((mpl::front<hello>::type::value == L'h'));
- BOOST_TEST((std::wstring(static_string::c_str<hello>::value)== L"hello world"));
- typedef mpl::push_back<hello, mpl::integral_c<wchar_t, L'!'> >::type hello2;
- BOOST_CHRONO_STATIC_ASSERT((boost::is_same<static_string::value_type<hello2>::type,wchar_t>::value),
- NOTHING, (mpl::value_type<hello2>::type));
- BOOST_TEST((std::wstring(static_string::c_str<hello2>::value)== L"hello world!"));
- }
-#endif
-#endif
     // no range matches nil
     {
         std::string str="";
@@ -142,10 +68,7 @@
     // empty range doesn't matches tree
     {
         using namespace boost;
- typedef basic_ptree<mpl::integral_c<char, 'a'>, mpl::int_<1> > tree;
- typedef insert<nil, mpl::pair<str_1<'a'>::type, mpl::int_<1> > >::type btree;
- BOOST_CHRONO_STATIC_ASSERT((boost::is_same<tree,btree>::value),
- NOTHING, (btree));
+ typedef insert<nil, mpl::pair<str_1<'a'>::type, mpl::int_<1> > >::type tree;
         {
             std::string str="";
             std::string::iterator b=str.begin();
@@ -183,21 +106,12 @@
     
     {
         using namespace boost;
- typedef
- basic_ptree<mpl::integral_c<char, 'a'>, mpl::int_<1>,
- basic_ptree<mpl::integral_c<char, 'b'>, mpl::int_<2> >
- > tree;
         typedef
         insert<
             insert<nil, mpl::pair<str_1<'a'>::type, mpl::int_<1> > >::type,
             mpl::pair<str_2<'a', 'b'>::type, mpl::int_<2> >
>::type
- btree;
- BOOST_CHRONO_STATIC_ASSERT((boost::is_same<tree,btree>::value),
- NOTHING, (insert<
- insert<nil, mpl::pair<str_1<'a'>::type, mpl::int_<1> > >::type,
- mpl::pair<str_2<'a', 'b'>::type, mpl::int_<2> >
- >::type));
+ tree;
         {
             std::string str="b";
             std::string::iterator b=str.begin();
@@ -225,22 +139,12 @@
     }
     {
         using namespace boost;
- typedef
- basic_ptree<mpl::integral_c<char, 'a'>, mpl::int_<1>,
- basic_ptree<mpl::integral_c<char, 'b'>, mpl::int_<2>
- >
- > tree;
         typedef
         insert<
             insert<nil, mpl::pair<str_2<'a', 'b'>::type, mpl::int_<2> > >::type,
             mpl::pair<str_1<'a'>::type, mpl::int_<1> >
>::type
- btree;
- BOOST_CHRONO_STATIC_ASSERT((boost::is_same<tree,btree>::value),
- NOTHING, (insert<
- insert<nil, mpl::pair<str_2<'a', 'b'>::type, mpl::int_<2> > >::type,
- mpl::pair<str_1<'a'>::type, mpl::int_<1> >
- >::type));
+ tree;
         {
             std::string str="b";
             std::string::iterator b=str.begin();
@@ -269,18 +173,11 @@
     {
         using namespace boost;
         typedef
- forest<
- basic_ptree<mpl::integral_c<char, 'a'>, mpl::int_<1> >,
- basic_ptree<mpl::integral_c<char, 'b'>, mpl::int_<2> >
- > tree;
- typedef
             insert<
                 insert<nil, mpl::pair<str_1<'a'>::type, mpl::int_<1> > >::type,
                 mpl::pair<str_1<'b'>::type, mpl::int_<2> >
>::type
- btree;
- BOOST_CHRONO_STATIC_ASSERT((boost::is_same<tree,btree>::value),
- NOTHING, (btree));
+ tree;
         {
             std::string str="";
             std::string::iterator b=str.begin();
@@ -316,23 +213,11 @@
     {
         using namespace boost;
         typedef
- forest<
- basic_ptree<mpl::integral_c<char, 'a'>, mpl::int_<-1>,
- basic_ptree<mpl::integral_c<char, 'b'>, mpl::int_<1> >
- >,
- basic_ptree<mpl::integral_c<char, 'b'>, mpl::int_<2> >
- > tree;
- typedef
             insert<
                 insert<nil, mpl::pair<str_2<'a', 'b'>::type, mpl::int_<1> > >::type,
                 mpl::pair<str_1<'b'>::type, mpl::int_<2> >
- >::type btree;
+ >::type tree;
             
- BOOST_CHRONO_STATIC_ASSERT((boost::is_same<tree,btree>::value),
- NOTHING, (insert<
- insert<nil, mpl::pair<str_2<'a', 'b'>::type, mpl::int_<1> > >::type,
- mpl::pair<str_1<'b'>::type, mpl::int_<2> >
- >::type));
         {
             std::string str="";
             std::string::iterator b=str.begin();
@@ -373,8 +258,6 @@
             BOOST_TEST((b == e));
         }
     }
-#if 0
-#endif
     return boost::report_errors();
 }
 


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