Implement minus flag.
This commit is contained in:
+24
-1
@@ -356,7 +356,7 @@ TEST(FormatterTest, Fill) {
|
||||
EXPECT_EQ("def**", str(Format("{0:*<5}") << TestString("def")));
|
||||
}
|
||||
|
||||
TEST(FormatterTest, PlusFlag) {
|
||||
TEST(FormatterTest, PlusSign) {
|
||||
EXPECT_EQ("+42", str(Format("{0:+}") << 42));
|
||||
EXPECT_EQ("-42", str(Format("{0:+}") << -42));
|
||||
EXPECT_EQ("+42", str(Format("{0:+}") << 42));
|
||||
@@ -379,6 +379,29 @@ TEST(FormatterTest, PlusFlag) {
|
||||
FormatError, "format specifier '+' requires numeric argument");
|
||||
}
|
||||
|
||||
TEST(FormatterTest, MinusSign) {
|
||||
EXPECT_EQ("42", str(Format("{0:-}") << 42));
|
||||
EXPECT_EQ("-42", str(Format("{0:-}") << -42));
|
||||
EXPECT_EQ("42", str(Format("{0:-}") << 42));
|
||||
EXPECT_THROW_MSG(Format("{0:-}") << 42u,
|
||||
FormatError, "format specifier '-' requires signed argument");
|
||||
EXPECT_EQ("42", str(Format("{0:-}") << 42l));
|
||||
EXPECT_THROW_MSG(Format("{0:-}") << 42ul,
|
||||
FormatError, "format specifier '-' requires signed argument");
|
||||
EXPECT_EQ("42", str(Format("{0:-}") << 42.0));
|
||||
EXPECT_EQ("42", str(Format("{0:-}") << 42.0l));
|
||||
EXPECT_THROW_MSG(Format("{0:-") << 'c',
|
||||
FormatError, "unmatched '{' in format");
|
||||
EXPECT_THROW_MSG(Format("{0:-}") << 'c',
|
||||
FormatError, "format specifier '-' requires numeric argument");
|
||||
EXPECT_THROW_MSG(Format("{0:-}") << "abc",
|
||||
FormatError, "format specifier '-' requires numeric argument");
|
||||
EXPECT_THROW_MSG(Format("{0:-}") << reinterpret_cast<void*>(0x42),
|
||||
FormatError, "format specifier '-' requires numeric argument");
|
||||
EXPECT_THROW_MSG(Format("{0:-}") << TestString(),
|
||||
FormatError, "format specifier '-' requires numeric argument");
|
||||
}
|
||||
|
||||
TEST(FormatterTest, ZeroFlag) {
|
||||
EXPECT_EQ("42", str(Format("{0:0}") << 42));
|
||||
EXPECT_EQ("-0042", str(Format("{0:05}") << -42));
|
||||
|
||||
Reference in New Issue
Block a user