]>
Commit | Line | Data |
---|---|---|
92f5a8d4 TL |
1 | /* |
2 | Copyright 2019 Glen Joseph Fernandes | |
3 | (glenjofe@gmail.com) | |
4 | ||
5 | Distributed under the Boost Software License, Version 1.0. | |
6 | (http://www.boost.org/LICENSE_1_0.txt) | |
7 | */ | |
8 | #include <boost/core/lightweight_test.hpp> | |
9 | #include <boost/utility/ostream_string.hpp> | |
10 | #include <sstream> | |
11 | #include <string> | |
12 | ||
13 | int main() | |
14 | { | |
15 | { | |
16 | std::ostringstream os; | |
17 | os.width(1); | |
18 | os.fill('.'); | |
19 | os.setf(std::ios_base::left, std::ios_base::adjustfield); | |
20 | boost::ostream_string(os, "xy", 2); | |
21 | BOOST_TEST(os.good()); | |
22 | BOOST_TEST(os.width() == 0); | |
23 | BOOST_TEST(os.str() == "xy"); | |
24 | } | |
25 | { | |
26 | std::wostringstream os; | |
27 | os.width(1); | |
28 | os.fill('.'); | |
29 | os.setf(std::ios_base::left, std::ios_base::adjustfield); | |
30 | boost::ostream_string(os, L"xy", 2); | |
31 | BOOST_TEST(os.good()); | |
32 | BOOST_TEST(os.width() == 0); | |
33 | BOOST_TEST(os.str() == L"xy"); | |
34 | } | |
35 | { | |
36 | std::ostringstream os; | |
37 | os.width(1); | |
38 | os.fill('.'); | |
39 | os.setf(std::ios_base::right, std::ios_base::adjustfield); | |
40 | boost::ostream_string(os, "xy", 2); | |
41 | BOOST_TEST(os.good()); | |
42 | BOOST_TEST(os.width() == 0); | |
43 | BOOST_TEST(os.str() == "xy"); | |
44 | } | |
45 | { | |
46 | std::wostringstream os; | |
47 | os.width(1); | |
48 | os.fill('.'); | |
49 | os.setf(std::ios_base::right, std::ios_base::adjustfield); | |
50 | boost::ostream_string(os, L"xy", 2); | |
51 | BOOST_TEST(os.good()); | |
52 | BOOST_TEST(os.width() == 0); | |
53 | BOOST_TEST(os.str() == L"xy"); | |
54 | } | |
55 | { | |
56 | std::ostringstream os; | |
57 | os.width(4); | |
58 | os.fill('.'); | |
59 | os.setf(std::ios_base::left, std::ios_base::adjustfield); | |
60 | boost::ostream_string(os, "xy", 2); | |
61 | BOOST_TEST(os.good()); | |
62 | BOOST_TEST(os.width() == 0); | |
63 | BOOST_TEST(os.str() == "xy.."); | |
64 | } | |
65 | { | |
66 | std::wostringstream os; | |
67 | os.width(4); | |
68 | os.fill(L'.'); | |
69 | os.setf(std::ios_base::left, std::ios_base::adjustfield); | |
70 | boost::ostream_string(os, L"xy", 2); | |
71 | BOOST_TEST(os.good()); | |
72 | BOOST_TEST(os.width() == 0); | |
73 | BOOST_TEST(os.str() == L"xy.."); | |
74 | } | |
75 | { | |
76 | std::ostringstream os; | |
77 | os.width(4); | |
78 | os.fill('.'); | |
79 | os.setf(std::ios_base::right, std::ios_base::adjustfield); | |
80 | boost::ostream_string(os, "xy", 2); | |
81 | BOOST_TEST(os.good()); | |
82 | BOOST_TEST(os.width() == 0); | |
83 | BOOST_TEST(os.str() == "..xy"); | |
84 | } | |
85 | { | |
86 | std::wostringstream os; | |
87 | os.width(4); | |
88 | os.fill(L'.'); | |
89 | os.setf(std::ios_base::right, std::ios_base::adjustfield); | |
90 | boost::ostream_string(os, L"xy", 2); | |
91 | BOOST_TEST(os.good()); | |
92 | BOOST_TEST(os.width() == 0); | |
93 | BOOST_TEST(os.str() == L"..xy"); | |
94 | } | |
95 | { | |
96 | std::ostringstream os; | |
97 | os.width(12); | |
98 | os.fill('.'); | |
99 | os.setf(std::ios_base::left, std::ios_base::adjustfield); | |
100 | boost::ostream_string(os, "xy", 2); | |
101 | BOOST_TEST(os.good()); | |
102 | BOOST_TEST(os.width() == 0); | |
103 | BOOST_TEST(os.str() == "xy.........."); | |
104 | } | |
105 | { | |
106 | std::wostringstream os; | |
107 | os.width(12); | |
108 | os.fill(L'.'); | |
109 | os.setf(std::ios_base::left, std::ios_base::adjustfield); | |
110 | boost::ostream_string(os, L"xy", 2); | |
111 | BOOST_TEST(os.good()); | |
112 | BOOST_TEST(os.width() == 0); | |
113 | BOOST_TEST(os.str() == L"xy.........."); | |
114 | } | |
115 | { | |
116 | std::ostringstream os; | |
117 | os.width(12); | |
118 | os.fill('.'); | |
119 | os.setf(std::ios_base::right, std::ios_base::adjustfield); | |
120 | boost::ostream_string(os, "xy", 2); | |
121 | BOOST_TEST(os.good()); | |
122 | BOOST_TEST(os.width() == 0); | |
123 | BOOST_TEST(os.str() == "..........xy"); | |
124 | } | |
125 | { | |
126 | std::wostringstream os; | |
127 | os.width(12); | |
128 | os.fill(L'.'); | |
129 | os.setf(std::ios_base::right, std::ios_base::adjustfield); | |
130 | boost::ostream_string(os, L"xy", 2); | |
131 | BOOST_TEST(os.good()); | |
132 | BOOST_TEST(os.width() == 0); | |
133 | BOOST_TEST(os.str() == L"..........xy"); | |
134 | } | |
135 | return boost::report_errors(); | |
136 | } |