1 /*
2 Copyright 2019-2020 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/io/quoted.hpp>
9 #include <boost/core/lightweight_test.hpp>
10 #include <sstream>
11 #include <string>
12
main()13 int main()
14 {
15 {
16 std::ostringstream os;
17 os.width(2);
18 os.fill('.');
19 os.setf(std::ios_base::left, std::ios_base::adjustfield);
20 os << boost::io::quoted("xy");
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(2);
28 os.fill(L'.');
29 os.setf(std::ios_base::left, std::ios_base::adjustfield);
30 os << boost::io::quoted(L"xy");
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(2);
38 os.fill('.');
39 os.setf(std::ios_base::right, std::ios_base::adjustfield);
40 os << boost::io::quoted("xy");
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(2);
48 os.fill(L'.');
49 os.setf(std::ios_base::right, std::ios_base::adjustfield);
50 os << boost::io::quoted(L"xy");
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(6);
58 os.fill('.');
59 os.setf(std::ios_base::left, std::ios_base::adjustfield);
60 os << boost::io::quoted("xy");
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(6);
68 os.fill(L'.');
69 os.setf(std::ios_base::left, std::ios_base::adjustfield);
70 os << boost::io::quoted(L"xy");
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(6);
78 os.fill('.');
79 os.setf(std::ios_base::right, std::ios_base::adjustfield);
80 os << boost::io::quoted("xy");
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(6);
88 os.fill(L'.');
89 os.setf(std::ios_base::right, std::ios_base::adjustfield);
90 os << boost::io::quoted(L"xy");
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(14);
98 os.fill('.');
99 os.setf(std::ios_base::left, std::ios_base::adjustfield);
100 os << boost::io::quoted("xy");
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(14);
108 os.fill(L'.');
109 os.setf(std::ios_base::left, std::ios_base::adjustfield);
110 os << boost::io::quoted(L"xy");
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(14);
118 os.fill('.');
119 os.setf(std::ios_base::right, std::ios_base::adjustfield);
120 os << boost::io::quoted("xy");
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(14);
128 os.fill(L'.');
129 os.setf(std::ios_base::right, std::ios_base::adjustfield);
130 os << boost::io::quoted(L"xy");
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 }
137