1 // Copyright (c) 2001-2011 Hartmut Kaiser
2 //
3 // Distributed under the Boost Software License, Version 1.0. (See accompanying
4 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
5
6 #include "auto.hpp"
7
8 ///////////////////////////////////////////////////////////////////////////////
main()9 int main()
10 {
11 {
12 BOOST_TEST((!traits::meta_create_exists<karma::domain, my_type>::value));
13 }
14
15 {
16 // test primitive types
17 BOOST_TEST(test_create_generator("true", true));
18 BOOST_TEST(test_create_generator("1", 1));
19 BOOST_TEST(test_create_generator("1.1", 1.1));
20 BOOST_TEST(test_create_generator("test", std::string("test")));
21 BOOST_TEST(test_create_generator("a", 'a'));
22 BOOST_TEST(test_create_generator(L"a", L'a'));
23
24 // test containers
25 std::vector<int> v;
26 v.push_back(0);
27 v.push_back(1);
28 v.push_back(2);
29 BOOST_TEST(test_create_generator("012", v));
30
31 std::list<int> l;
32 l.push_back(0);
33 l.push_back(1);
34 l.push_back(2);
35 BOOST_TEST(test_create_generator("012", l));
36
37 // test optional
38 boost::optional<int> o;
39 BOOST_TEST(test_create_generator("", o));
40 o = 1;
41 BOOST_TEST(test_create_generator("1", o));
42
43 // test alternative
44 boost::variant<int, double, float, std::string> vv;
45 vv = 1;
46 BOOST_TEST(test_create_generator("1", vv));
47 vv = 1.0;
48 BOOST_TEST(test_create_generator("1.0", vv));
49 vv = 1.0f;
50 BOOST_TEST(test_create_generator("1.0", vv));
51 vv = "some string";
52 BOOST_TEST(test_create_generator("some string", vv));
53
54 // test fusion sequence
55 std::pair<int, double> p (1, 2.0);
56 BOOST_TEST(test_create_generator("12.0", p));
57 }
58
59 {
60 // test primitive types
61 // BOOST_TEST(test_create_generator_auto("true", true));
62 // BOOST_TEST(test_create_generator_auto("1", 1));
63 // BOOST_TEST(test_create_generator_auto("1.1", 1.1));
64 // BOOST_TEST(test_create_generator_auto("test", std::string("test")));
65 // BOOST_TEST(test_create_generator_auto("a", 'a'));
66 // BOOST_TEST(test_create_generator_auto(L"a", L'a'));
67
68 // test containers
69 std::vector<int> v;
70 v.push_back(0);
71 v.push_back(1);
72 v.push_back(2);
73 BOOST_TEST(test_create_generator_auto("012", v));
74
75 std::list<int> l;
76 l.push_back(0);
77 l.push_back(1);
78 l.push_back(2);
79 BOOST_TEST(test_create_generator_auto("012", l));
80
81 // test optional
82 boost::optional<int> o;
83 BOOST_TEST(test_create_generator_auto("", o));
84 o = 1;
85 BOOST_TEST(test_create_generator_auto("1", o));
86
87 // test alternative
88 boost::variant<int, double, float, std::string> vv;
89 vv = 1;
90 BOOST_TEST(test_create_generator_auto("1", vv));
91 vv = 1.0;
92 BOOST_TEST(test_create_generator_auto("1.0", vv));
93 vv = 1.0f;
94 BOOST_TEST(test_create_generator_auto("1.0", vv));
95 vv = "some string";
96 BOOST_TEST(test_create_generator_auto("some string", vv));
97
98 // test fusion sequence
99 std::pair<int, double> p (1, 2.0);
100 BOOST_TEST(test_create_generator_auto("12.0", p));
101 }
102
103 return boost::report_errors();
104 }
105