Add a test from example.

This commit is contained in:
Victor Zverovich 2012-12-13 08:01:47 -08:00
parent 228fc8758f
commit d29f31851e

View File

@ -665,11 +665,19 @@ TEST(FormatterTest, FormatterAppend) {
EXPECT_EQ("part1part2", format.str()); EXPECT_EQ("part1part2", format.str());
} }
TEST(FormatterTest, FormatterExample) { TEST(FormatterTest, FormatterExamples) {
Formatter format; Formatter format;
format("Current point:\n"); format("Current point:\n");
format("({0:+f}, {1:+f})\n") << -3.14 << 3.14; format("({0:+f}, {1:+f})\n") << -3.14 << 3.14;
EXPECT_EQ("Current point:\n(-3.140000, +3.140000)\n", format.str()); EXPECT_EQ("Current point:\n(-3.140000, +3.140000)\n", format.str());
{
fmt::Formatter format;
for (int i = 0; i < 10; i++)
format("{0}") << i;
std::string s = format.str(); // s == 0123456789
EXPECT_EQ("0123456789", s);
}
} }
TEST(FormatterTest, ArgInserter) { TEST(FormatterTest, ArgInserter) {