|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r58769 - trunk/libs/spirit/test/karma
From: hartmut.kaiser_at_[hidden]
Date: 2010-01-06 11:00:19
Author: hkaiser
Date: 2010-01-06 11:00:18 EST (Wed, 06 Jan 2010)
New Revision: 58769
URL: http://svn.boost.org/trac/boost/changeset/58769
Log:
Spirit: added more tests for Karma auto_
Text files modified:
trunk/libs/spirit/test/karma/auto.cpp | 56 ++++++++++++++++++++++++++++++++++++++++
1 files changed, 56 insertions(+), 0 deletions(-)
Modified: trunk/libs/spirit/test/karma/auto.cpp
==============================================================================
--- trunk/libs/spirit/test/karma/auto.cpp (original)
+++ trunk/libs/spirit/test/karma/auto.cpp 2010-01-06 11:00:18 EST (Wed, 06 Jan 2010)
@@ -228,6 +228,62 @@
}
{
+ using karma::auto_;
+ using karma::upper;
+ using spirit_test::test;
+ using spirit_test::test_delimited;
+
+ // test primitive types
+ BOOST_TEST(test("true", auto_(true)));
+ BOOST_TEST(test("1", auto_(1)));
+ BOOST_TEST(test("1.1", auto_(1.1)));
+ BOOST_TEST(test("test", auto_("test")));
+ BOOST_TEST(test(L"test", auto_(L"test")));
+ BOOST_TEST(test("a", auto_('a')));
+ BOOST_TEST(test(L"a", auto_(L'a')));
+
+ BOOST_TEST(test("TRUE", upper[auto_(true)]));
+ BOOST_TEST(test("TEST", upper[auto_("test")]));
+
+ // test containers
+ std::vector<int> v;
+ v.push_back(0);
+ v.push_back(1);
+ v.push_back(2);
+ BOOST_TEST(test("012", auto_(v)));
+ BOOST_TEST(test_delimited("0,1,2,", auto_(v), ','));
+
+ std::list<int> l;
+ l.push_back(0);
+ l.push_back(1);
+ l.push_back(2);
+ BOOST_TEST(test("012", auto_(l)));
+ BOOST_TEST(test_delimited("0,1,2,", auto_(l), ','));
+
+ // test optional
+ boost::optional<int> o;
+ BOOST_TEST(test("", auto_(o)));
+ o = 1;
+ BOOST_TEST(test("1", auto_(o)));
+
+ // test alternative
+ boost::variant<int, double, float, std::string> vv;
+ vv = 1;
+ BOOST_TEST(test("1", auto_(vv)));
+ vv = 1.0;
+ BOOST_TEST(test("1.0", auto_(vv)));
+ vv = 1.0f;
+ BOOST_TEST(test("1.0", auto_(vv)));
+ vv = "some string";
+ BOOST_TEST(test("some string", auto_(vv)));
+
+ // test fusion sequence
+ std::pair<int, double> p (1, 2.0);
+ BOOST_TEST(test("12.0", auto_, p));
+ BOOST_TEST(test_delimited("1,2.0,", auto_(p), ','));
+ }
+
+ {
using spirit_test::test;
using spirit_test::test_delimited;
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