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:
@@ -10,9 +10,7 @@
|
|||||||
BFormat::BFormat()
|
BFormat::BFormat()
|
||||||
{
|
{
|
||||||
const BLocale* locale = BLocaleRoster::Default()->GetDefaultLocale();
|
const BLocale* locale = BLocaleRoster::Default()->GetDefaultLocale();
|
||||||
fInitStatus = locale->GetFormattingConventions(&fConventions);
|
SetLocale(*locale);
|
||||||
if (fInitStatus == B_OK)
|
|
||||||
fInitStatus = locale->GetLanguage(&fLanguage);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ BTimeUnitFormat::BTimeUnitFormat()
|
|||||||
Inherited(),
|
Inherited(),
|
||||||
fFormatter(NULL)
|
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
|
void
|
||||||
DurationFormatTest::TestDuration()
|
DurationFormatTest::TestDuration()
|
||||||
{
|
{
|
||||||
@@ -90,6 +106,8 @@ DurationFormatTest::AddTests(BTestSuite& parent)
|
|||||||
{
|
{
|
||||||
CppUnit::TestSuite& suite = *new CppUnit::TestSuite("DurationFormatTest");
|
CppUnit::TestSuite& suite = *new CppUnit::TestSuite("DurationFormatTest");
|
||||||
|
|
||||||
|
suite.addTest(new CppUnit::TestCaller<DurationFormatTest>(
|
||||||
|
"DurationFormatTest::TestDefault", &DurationFormatTest::TestDefault));
|
||||||
suite.addTest(new CppUnit::TestCaller<DurationFormatTest>(
|
suite.addTest(new CppUnit::TestCaller<DurationFormatTest>(
|
||||||
"DurationFormatTest::TestDuration", &DurationFormatTest::TestDuration));
|
"DurationFormatTest::TestDuration", &DurationFormatTest::TestDuration));
|
||||||
suite.addTest(new CppUnit::TestCaller<DurationFormatTest>(
|
suite.addTest(new CppUnit::TestCaller<DurationFormatTest>(
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ public:
|
|||||||
DurationFormatTest();
|
DurationFormatTest();
|
||||||
virtual ~DurationFormatTest();
|
virtual ~DurationFormatTest();
|
||||||
|
|
||||||
|
void TestDefault();
|
||||||
void TestDuration();
|
void TestDuration();
|
||||||
void TestTimeUnit();
|
void TestTimeUnit();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user