added method & tests to the class NumberFormatter for bool values

This commit is contained in:
Marian Krivos
2009-03-23 20:10:51 +00:00
parent 764bbf2e1d
commit fd98b17390
3 changed files with 80 additions and 41 deletions

View File

@@ -12,14 +12,14 @@
// execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following:
//
//
// The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by
// a source language processor.
//
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
@@ -60,13 +60,13 @@ void NumberFormatterTest::testFormat()
assert (NumberFormatter::format((unsigned) 123) == "123");
assert (NumberFormatter::format((unsigned) 123, 5) == " 123");
assert (NumberFormatter::format0((unsigned) 123, 5) == "00123");
assert (NumberFormatter::format((long) 123) == "123");
assert (NumberFormatter::format((long) -123) == "-123");
assert (NumberFormatter::format((long) -123, 5) == " -123");
assert (NumberFormatter::format((unsigned long) 123) == "123");
assert (NumberFormatter::format((unsigned long) 123, 5) == " 123");
assert (NumberFormatter::format((unsigned long) 123, 5) == " 123");
#if defined(POCO_HAVE_INT64)
assert (NumberFormatter::format((Int64) 123) == "123");
@@ -74,7 +74,7 @@ void NumberFormatterTest::testFormat()
assert (NumberFormatter::format((Int64) -123, 5) == " -123");
assert (NumberFormatter::format((UInt64) 123) == "123");
assert (NumberFormatter::format((UInt64) 123, 5) == " 123");
assert (NumberFormatter::format((UInt64) 123, 5) == " 123");
#endif
if (sizeof(void*) == 4)
@@ -85,10 +85,17 @@ void NumberFormatterTest::testFormat()
{
assert (NumberFormatter::format((void*) 0x12345678) == "0000000012345678");
}
assert (NumberFormatter::format(12.25) == "12.25");
assert (NumberFormatter::format(12.25, 4) == "12.2500");
assert (NumberFormatter::format(12.25, 8, 4) == " 12.2500");
assert (NumberFormatter::format(true, NumberFormatter::FMT_TRUE_FALSE) == "true");
assert (NumberFormatter::format(false, NumberFormatter::FMT_TRUE_FALSE) == "false");
assert (NumberFormatter::format(true, NumberFormatter::FMT_YES_NO) == "yes");
assert (NumberFormatter::format(false, NumberFormatter::FMT_YES_NO) == "no");
assert (NumberFormatter::format(true, NumberFormatter::FMT_ON_OFF) == "on");
assert (NumberFormatter::format(false, NumberFormatter::FMT_ON_OFF) == "off");
}