Test double formatting.

This commit is contained in:
Victor Zverovich
2012-12-10 12:16:02 -08:00
parent 27b8ba06e8
commit d73306bdce
2 changed files with 49 additions and 4 deletions

View File

@@ -157,11 +157,14 @@ void fmt::Formatter::FormatDouble(
T value, unsigned flags, int width, int precision, char type) {
// Check type.
switch (type) {
case 0:
type = 'g';
break;
case 'e': case 'E': case 'f': case 'F': case 'g': case 'G':
break;
default:
// TODO: error
break;
throw FormatError(
str(fmt::Format("unknown format code '{0}' for double") << type));
}
// Build format string.
@@ -181,7 +184,7 @@ void fmt::Formatter::FormatDouble(
}
if (IsLongDouble<T>::VALUE)
*format_ptr++ = 'L';
*format_ptr++ = type ? type : 'g';
*format_ptr++ = type;
*format_ptr = '\0';
// Format using snprintf.