format: set ostream precision as if for strings
ostream conversions are converted to strings anyway, so we should treat them as such earlier in the process.
This commit is contained in:
parent
fad8181842
commit
c26c687912
@ -225,12 +225,12 @@ namespace util { namespace format { namespace detail {
|
|||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
case specifier::kind::STRING:
|
case specifier::kind::STRING:
|
||||||
|
case specifier::kind::OSTREAM:
|
||||||
return std::numeric_limits<int>::max ();
|
return std::numeric_limits<int>::max ();
|
||||||
|
|
||||||
case specifier::kind::POINTER:
|
case specifier::kind::POINTER:
|
||||||
case specifier::kind::CHARACTER:
|
case specifier::kind::CHARACTER:
|
||||||
case specifier::kind::ESCAPE:
|
case specifier::kind::ESCAPE:
|
||||||
case specifier::kind::OSTREAM:
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,6 +2,18 @@
|
|||||||
|
|
||||||
#include "tap.hpp"
|
#include "tap.hpp"
|
||||||
|
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
struct userobj { };
|
||||||
|
|
||||||
|
static std::ostream&
|
||||||
|
operator<< (std::ostream &os, const userobj&)
|
||||||
|
{
|
||||||
|
return os << "userobj";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
int
|
int
|
||||||
main (void)
|
main (void)
|
||||||
{
|
{
|
||||||
@ -121,6 +133,7 @@ main (void)
|
|||||||
CHECK_RENDER ("%.64s", "foo", "foo");
|
CHECK_RENDER ("%.64s", "foo", "foo");
|
||||||
CHECK_RENDER ("%3.1s", " f", "foo");
|
CHECK_RENDER ("%3.1s", " f", "foo");
|
||||||
CHECK_RENDER ("%-3.1s", "f ", "foo");
|
CHECK_RENDER ("%-3.1s", "f ", "foo");
|
||||||
|
CHECK_RENDER ("%!", "userobj", userobj {});
|
||||||
|
|
||||||
CHECK_RENDER ("%p", "0x1234567", (void*)0x01234567);
|
CHECK_RENDER ("%p", "0x1234567", (void*)0x01234567);
|
||||||
CHECK_RENDER ("%p", "0x1234567", (int*)0x01234567);
|
CHECK_RENDER ("%p", "0x1234567", (int*)0x01234567);
|
||||||
|
Loading…
Reference in New Issue
Block a user