57 std::ostringstream
os;
60 const std::string foo =
"foo";
61 const char *
const bar =
"bar";
62 const double pi = 3.14159265;
64 const std::string weather =
"partly cloudy";
65 char *nc =
const_cast<char *
>(
"non const");
67 os << to_string(seven) << std::endl;
68 os << to_string(foo) << std::endl;
69 os << to_string(bar) << std::endl;
70 os << to_string(pi) << std::endl;
71 os << to_string(three) << std::endl;
72 os << to_string(
true) << std::endl;
73 os << to_string(
false) << std::endl;
74 os <<
prints(
"pi",
"is", std::string(
"not"), 3,
"nor is it", seven,
';',
"it",
"is", pi,
"...") << std::endl;
75 os <<
printfmt(
"pi is %r %s nor is it %s ; it is %s... (and has %s%% less %s!)",
"not", 3, seven, pi, 99, std::string(
"fat")) << std::endl;
76 os <<
printfmt(
"the year is %s and the weather is %R", 2015, weather) << std::endl;
77 os <<
printfmt(
"where am %s? is it still %s?",
'I', 2015) << std::endl;
78 os <<
printfmt(
"no, it's %s... bring out yer dedd%s", 1666) << std::endl;
80 os <<
printfmt(
"no wait... save%s 99.9999%%!") << std::endl;
81 os <<
printfmt(
"extra argument is here", 1) << std::endl;
82 os <<
printfmt(
"is the question %s or %s?",
true,
false) << std::endl;
83 os <<
printfmt(
"more extra arguments are here", 1, 2, 3, 4) << std::endl;
84 os <<
printfmt(
"null string '%s'",
static_cast<const char *
>(
nullptr)) << std::endl;
85 os <<
printfmt(
"nullptr '%s'",
nullptr) << std::endl;
86 os <<
printfmt(
"%s=%s %s", foo, bar, nc) << std::endl;
89 const std::string exstr =
"bad foo";
92 catch (
const std::exception &e)
94 os <<
prints(
"EX1:", e.what()) << std::endl;
100 catch (
const std::exception &e)
102 os <<
prints(
"EX2:", e.what()) << std::endl;
104 const std::string actual =
os.str();