From 64a84f3f9b82efa0738cafdf596f1fa9d31caa66 Mon Sep 17 00:00:00 2001 From: Andrey Semashev Date: Mon, 30 Aug 2010 15:37:58 +0000 Subject: [PATCH] Added explicit std qualifiers to avoid name clash of boost and STL equal algorithms [SVN r65133] --- test/examples.cpp | 104 ++++++++++++++++++++++------------------------ 1 file changed, 49 insertions(+), 55 deletions(-) diff --git a/test/examples.cpp b/test/examples.cpp index 3b7fbaa..1e0b69b 100644 --- a/test/examples.cpp +++ b/test/examples.cpp @@ -11,6 +11,7 @@ #include #include #include +#include #include #include @@ -18,86 +19,81 @@ int test_main( int /*argc*/, char* /*argv*/[] ) { - using namespace std; using namespace boost; - + // Use tokenizer { - const string test_string = ";;Hello|world||-foo--bar;yow;baz|"; - string answer[] = { "Hello", "world", "foo", "bar", "yow", "baz" }; - typedef tokenizer > Tok; - char_separator sep("-;|"); - Tok t(test_string, sep); - BOOST_REQUIRE(equal(t.begin(),t.end(),answer)); + const std::string test_string = ";;Hello|world||-foo--bar;yow;baz|"; + std::string answer[] = { "Hello", "world", "foo", "bar", "yow", "baz" }; + typedef tokenizer > Tok; + char_separator sep("-;|"); + Tok t(test_string, sep); + BOOST_REQUIRE(std::equal(t.begin(),t.end(),answer)); } { - const string test_string = ";;Hello|world||-foo--bar;yow;baz|"; - string answer[] = { "", "", "Hello", "|", "world", "|", "", "|", "", - "foo", "", "bar", "yow", "baz", "|", "" }; - typedef tokenizer > Tok; - char_separator sep("-;", "|", boost::keep_empty_tokens); - Tok t(test_string, sep); - BOOST_REQUIRE(equal(t.begin(), t.end(), answer)); + const std::string test_string = ";;Hello|world||-foo--bar;yow;baz|"; + std::string answer[] = { "", "", "Hello", "|", "world", "|", "", "|", "", + "foo", "", "bar", "yow", "baz", "|", "" }; + typedef tokenizer > Tok; + char_separator sep("-;", "|", boost::keep_empty_tokens); + Tok t(test_string, sep); + BOOST_REQUIRE(std::equal(t.begin(), t.end(), answer)); } { - const string test_string = "This,,is, a.test.."; - string answer[] = {"This","is","a","test"}; + const std::string test_string = "This,,is, a.test.."; + std::string answer[] = {"This","is","a","test"}; typedef tokenizer<> Tok; Tok t(test_string); - BOOST_REQUIRE(equal(t.begin(),t.end(),answer)); + BOOST_REQUIRE(std::equal(t.begin(),t.end(),answer)); } { - const string test_string = "Field 1,\"embedded,comma\",quote \\\", escape \\\\"; - string answer[] = {"Field 1","embedded,comma","quote \""," escape \\"}; + const std::string test_string = "Field 1,\"embedded,comma\",quote \\\", escape \\\\"; + std::string answer[] = {"Field 1","embedded,comma","quote \""," escape \\"}; typedef tokenizer > Tok; Tok t(test_string); - BOOST_REQUIRE(equal(t.begin(),t.end(),answer)); - + BOOST_REQUIRE(std::equal(t.begin(),t.end(),answer)); } { - const string test_string = ",1,;2\\\";3\\;,4,5^\\,\'6,7\';"; - string answer[] = {"","1","","2\"","3;","4","5\\","6,7",""}; + const std::string test_string = ",1,;2\\\";3\\;,4,5^\\,\'6,7\';"; + std::string answer[] = {"","1","","2\"","3;","4","5\\","6,7",""}; typedef tokenizer > Tok; escaped_list_separator sep("\\^",",;","\"\'"); Tok t(test_string,sep); - BOOST_REQUIRE(equal(t.begin(),t.end(),answer)); - + BOOST_REQUIRE(std::equal(t.begin(),t.end(),answer)); } { - const string test_string = "12252001"; - string answer[] = {"12","25","2001"}; + const std::string test_string = "12252001"; + std::string answer[] = {"12","25","2001"}; typedef tokenizer Tok; boost::array offsets = {{2,2,4}}; offset_separator func(offsets.begin(),offsets.end()); Tok t(test_string,func); - BOOST_REQUIRE(equal(t.begin(),t.end(),answer)); - + BOOST_REQUIRE(std::equal(t.begin(),t.end(),answer)); } // Use token_iterator_generator { - - const string test_string = "This,,is, a.test.."; - string answer[] = {"This","is","a","test"}; + const std::string test_string = "This,,is, a.test.."; + std::string answer[] = {"This","is","a","test"}; typedef token_iterator_generator >::type Iter; - Iter begin = make_token_iterator(test_string.begin(), + Iter begin = make_token_iterator(test_string.begin(), test_string.end(),char_delimiters_separator()); Iter end; - BOOST_REQUIRE(equal(begin,end,answer)); + BOOST_REQUIRE(std::equal(begin,end,answer)); } { - const string test_string = "Field 1,\"embedded,comma\",quote \\\", escape \\\\"; - string answer[] = {"Field 1","embedded,comma","quote \""," escape \\"}; + const std::string test_string = "Field 1,\"embedded,comma\",quote \\\", escape \\\\"; + std::string answer[] = {"Field 1","embedded,comma","quote \""," escape \\"}; typedef token_iterator_generator >::type Iter; - Iter begin = make_token_iterator(test_string.begin(), + Iter begin = make_token_iterator(test_string.begin(), test_string.end(),escaped_list_separator()); Iter begin_c(begin); Iter end; - BOOST_REQUIRE(equal(begin,end,answer)); + BOOST_REQUIRE(std::equal(begin,end,answer)); while(begin_c != end) { @@ -105,39 +101,37 @@ int test_main( int /*argc*/, char* /*argv*/[] ) ++begin_c; } BOOST_REQUIRE(begin_c.at_end()); - } { - const string test_string = "12252001"; - string answer[] = {"12","25","2001"}; + const std::string test_string = "12252001"; + std::string answer[] = {"12","25","2001"}; typedef token_iterator_generator::type Iter; boost::array offsets = {{2,2,4}}; offset_separator func(offsets.begin(),offsets.end()); - Iter begin = make_token_iterator(test_string.begin(), + Iter begin = make_token_iterator(test_string.begin(), test_string.end(),func); - Iter end= make_token_iterator(test_string.end(), + Iter end= make_token_iterator(test_string.end(), test_string.end(),func); - BOOST_REQUIRE(equal(begin,end,answer)); - + BOOST_REQUIRE(std::equal(begin,end,answer)); } - + // Test copying { - const string test_string = "abcdef"; + const std::string test_string = "abcdef"; token_iterator_generator::type beg, end, other; boost::array ar = {{1,2,3}}; offset_separator f(ar.begin(),ar.end()); - beg = make_token_iterator(test_string.begin(),test_string.end(),f); - + beg = make_token_iterator(test_string.begin(),test_string.end(),f); + ++beg; other = beg; ++other; BOOST_REQUIRE(*beg=="bc"); BOOST_REQUIRE(*other=="def"); - - other = make_token_iterator(test_string.begin(), + + other = make_token_iterator(test_string.begin(), test_string.end(),f); BOOST_REQUIRE(*other=="a"); @@ -145,10 +139,10 @@ int test_main( int /*argc*/, char* /*argv*/[] ) // Test non-default constructed char_delimiters_separator { - const string test_string = "how,are you, doing"; - string answer[] = {"how",",","are you",","," doing"}; + const std::string test_string = "how,are you, doing"; + std::string answer[] = {"how",",","are you",","," doing"}; tokenizer<> t(test_string,char_delimiters_separator(true,",","")); - BOOST_REQUIRE(equal(t.begin(),t.end(),answer)); + BOOST_REQUIRE(std::equal(t.begin(),t.end(),answer)); } return 0;