Fix initialization of BTimeUnitFormat
* The default constructor must configure it for the default locale * Fix uptime not showing in AboutSystem * Add a testcase for this
This commit is contained in:
parent
e3857211d3
commit
df4a02e0fa
|
@ -10,9 +10,7 @@
|
|||
BFormat::BFormat()
|
||||
{
|
||||
const BLocale* locale = BLocaleRoster::Default()->GetDefaultLocale();
|
||||
fInitStatus = locale->GetFormattingConventions(&fConventions);
|
||||
if (fInitStatus == B_OK)
|
||||
fInitStatus = locale->GetLanguage(&fLanguage);
|
||||
SetLocale(*locale);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -39,6 +39,7 @@ BTimeUnitFormat::BTimeUnitFormat()
|
|||
Inherited(),
|
||||
fFormatter(NULL)
|
||||
{
|
||||
SetLanguage(fLanguage);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -23,6 +23,22 @@ DurationFormatTest::~DurationFormatTest()
|
|||
}
|
||||
|
||||
|
||||
void
|
||||
DurationFormatTest::TestDefault()
|
||||
{
|
||||
BDurationFormat format;
|
||||
BString buffer;
|
||||
BString expected;
|
||||
|
||||
status_t result = format.Format(buffer, 0, 800000000000ll);
|
||||
CPPUNIT_ASSERT_EQUAL(B_OK, result);
|
||||
// The exact format and language used depends on the locale settings, but
|
||||
// we can assume that whatever they are, it should put something in the
|
||||
// string.
|
||||
CPPUNIT_ASSERT(buffer.Length() > 0);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
DurationFormatTest::TestDuration()
|
||||
{
|
||||
|
@ -90,6 +106,8 @@ DurationFormatTest::AddTests(BTestSuite& parent)
|
|||
{
|
||||
CppUnit::TestSuite& suite = *new CppUnit::TestSuite("DurationFormatTest");
|
||||
|
||||
suite.addTest(new CppUnit::TestCaller<DurationFormatTest>(
|
||||
"DurationFormatTest::TestDefault", &DurationFormatTest::TestDefault));
|
||||
suite.addTest(new CppUnit::TestCaller<DurationFormatTest>(
|
||||
"DurationFormatTest::TestDuration", &DurationFormatTest::TestDuration));
|
||||
suite.addTest(new CppUnit::TestCaller<DurationFormatTest>(
|
||||
|
|
|
@ -15,6 +15,7 @@ public:
|
|||
DurationFormatTest();
|
||||
virtual ~DurationFormatTest();
|
||||
|
||||
void TestDefault();
|
||||
void TestDuration();
|
||||
void TestTimeUnit();
|
||||
|
||||
|
|
Loading…
Reference in New Issue