1 /*
2 Copyright 2019 Glen Joseph Fernandes
3 ([email protected])
4 
5 Distributed under the Boost Software License, Version 1.0.
6 (http://www.boost.org/LICENSE_1_0.txt)
7 */
8 #include <boost/io/ostream_joiner.hpp>
9 #include <boost/core/is_same.hpp>
10 #include <boost/core/lightweight_test.hpp>
11 #include <sstream>
12 
test_char_type()13 void test_char_type()
14 {
15     BOOST_TEST((boost::core::is_same<char,
16         boost::io::ostream_joiner<const char*>::char_type>::value));
17 }
18 
test_traits_type()19 void test_traits_type()
20 {
21     BOOST_TEST((boost::core::is_same<std::char_traits<char>,
22         boost::io::ostream_joiner<const char*>::traits_type>::value));
23 }
24 
test_ostream_type()25 void test_ostream_type()
26 {
27     BOOST_TEST((boost::core::is_same<std::ostream,
28         boost::io::ostream_joiner<const char*>::ostream_type>::value));
29 }
30 
test_iterator_category()31 void test_iterator_category()
32 {
33     BOOST_TEST((boost::core::is_same<std::output_iterator_tag,
34         boost::io::ostream_joiner<const char*>::iterator_category>::value));
35 }
36 
test_value_type()37 void test_value_type()
38 {
39     BOOST_TEST((boost::core::is_same<void,
40         boost::io::ostream_joiner<const char*>::value_type>::value));
41 }
42 
test_difference_type()43 void test_difference_type()
44 {
45     BOOST_TEST((boost::core::is_same<void,
46         boost::io::ostream_joiner<const char*>::difference_type>::value));
47 }
48 
test_pointer()49 void test_pointer()
50 {
51     BOOST_TEST((boost::core::is_same<void,
52         boost::io::ostream_joiner<const char*>::pointer>::value));
53 }
54 
test_reference()55 void test_reference()
56 {
57     BOOST_TEST((boost::core::is_same<void,
58         boost::io::ostream_joiner<const char*>::reference>::value));
59 }
60 
test_construct()61 void test_construct()
62 {
63     std::ostringstream o;
64     boost::io::ostream_joiner<const char*> j(o, ",");
65     BOOST_TEST(o.str().empty());
66 }
67 
test_assign()68 void test_assign()
69 {
70     std::ostringstream o;
71     boost::io::ostream_joiner<const char*> j(o, ",");
72     j = 1;
73     BOOST_TEST_EQ(o.str(), "1");
74     j = '2';
75     BOOST_TEST_EQ(o.str(), "1,2");
76     j = "3";
77     BOOST_TEST_EQ(o.str(), "1,2,3");
78 }
79 
test_increment()80 void test_increment()
81 {
82     std::ostringstream o;
83     boost::io::ostream_joiner<const char*> j(o, ",");
84     BOOST_TEST_EQ(&++j, &j);
85 }
86 
test_post_increment()87 void test_post_increment()
88 {
89     std::ostringstream o;
90     boost::io::ostream_joiner<const char*> j(o, ",");
91     BOOST_TEST_EQ(&j++, &j);
92 }
93 
test_value()94 void test_value()
95 {
96     std::ostringstream o;
97     boost::io::ostream_joiner<const char*> j(o, ",");
98     BOOST_TEST_EQ(&*j, &j);
99 }
100 
main()101 int main()
102 {
103     test_char_type();
104     test_traits_type();
105     test_ostream_type();
106     test_iterator_category();
107     test_value_type();
108     test_difference_type();
109     test_pointer();
110     test_reference();
111     test_construct();
112     test_assign();
113     test_increment();
114     test_post_increment();
115     test_value();
116     return boost::report_errors();
117 }
118