mirror of
https://github.com/fmtlib/fmt.git
synced 2024-12-24 21:16:56 +00:00
Test precision.
This commit is contained in:
parent
c538dd5033
commit
0552f5b809
@ -227,7 +227,7 @@ TEST(PrintfTest, DynamicWidth) {
|
||||
"argument index is out of range in format");
|
||||
}
|
||||
|
||||
TEST(PrintfTest, Precision) {
|
||||
TEST(PrintfTest, IntPrecision) {
|
||||
EXPECT_PRINTF("00042", "%.5d", 42);
|
||||
EXPECT_PRINTF("-00042", "%.5d", -42);
|
||||
EXPECT_PRINTF("00042", "%.5x", 0x42);
|
||||
@ -248,6 +248,21 @@ TEST(PrintfTest, Precision) {
|
||||
EXPECT_PRINTF("00042 ", "%-#10.5o", 042);
|
||||
}
|
||||
|
||||
TEST(PrintfTest, FloatPrecision) {
|
||||
char buffer[BUFFER_SIZE];
|
||||
SPrintf(buffer, "%.3e", 1234.5678);
|
||||
EXPECT_PRINTF(buffer, "%.3e", 1234.5678);
|
||||
EXPECT_PRINTF("1234.568", "%.3f", 1234.5678);
|
||||
SPrintf(buffer, "%.3g", 1234.5678);
|
||||
EXPECT_PRINTF(buffer, "%.3g", 1234.5678);
|
||||
SPrintf(buffer, "%.3a", 1234.5678);
|
||||
EXPECT_PRINTF(buffer, "%.3a", 1234.5678);
|
||||
}
|
||||
|
||||
TEST(PrintfTest, IgnorePrecisionForNonNumericArg) {
|
||||
EXPECT_PRINTF("abc", "%.5s", "abc");
|
||||
}
|
||||
|
||||
// TODO: test length and type specifier
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user