hrev47950 adds 1 changeset to branch 'master' old head: e3857211d305a595c2d0b58768f25623d5967675 new head: df4a02e0facdf184f33900d2137532bb37e0442d overview: http://cgit.haiku-os.org/haiku/log/?qt=range&q=df4a02e+%5Ee385721 ---------------------------------------------------------------------------- df4a02e: 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 [ Adrien Destugues <pulkomandy@xxxxxxxxx> ] ---------------------------------------------------------------------------- Revision: hrev47950 Commit: df4a02e0facdf184f33900d2137532bb37e0442d URL: http://cgit.haiku-os.org/haiku/commit/?id=df4a02e Author: Adrien Destugues <pulkomandy@xxxxxxxxx> Date: Thu Oct 2 08:23:31 2014 UTC ---------------------------------------------------------------------------- 4 files changed, 21 insertions(+), 3 deletions(-) src/kits/locale/Format.cpp | 4 +--- src/kits/locale/TimeUnitFormat.cpp | 1 + src/tests/kits/locale/DurationFormatTest.cpp | 18 ++++++++++++++++++ src/tests/kits/locale/DurationFormatTest.h | 1 + ---------------------------------------------------------------------------- diff --git a/src/kits/locale/Format.cpp b/src/kits/locale/Format.cpp index 5fb4513..610be0d 100644 --- a/src/kits/locale/Format.cpp +++ b/src/kits/locale/Format.cpp @@ -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); } diff --git a/src/kits/locale/TimeUnitFormat.cpp b/src/kits/locale/TimeUnitFormat.cpp index 51a65d4..036ad74 100644 --- a/src/kits/locale/TimeUnitFormat.cpp +++ b/src/kits/locale/TimeUnitFormat.cpp @@ -39,6 +39,7 @@ BTimeUnitFormat::BTimeUnitFormat() Inherited(), fFormatter(NULL) { + SetLanguage(fLanguage); } diff --git a/src/tests/kits/locale/DurationFormatTest.cpp b/src/tests/kits/locale/DurationFormatTest.cpp index 8c88099..018cc98 100644 --- a/src/tests/kits/locale/DurationFormatTest.cpp +++ b/src/tests/kits/locale/DurationFormatTest.cpp @@ -24,6 +24,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() { BDurationFormat format; @@ -91,6 +107,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>( "DurationFormatTest::TestTimeUnit", &DurationFormatTest::TestTimeUnit)); diff --git a/src/tests/kits/locale/DurationFormatTest.h b/src/tests/kits/locale/DurationFormatTest.h index 80683dc..8338774 100644 --- a/src/tests/kits/locale/DurationFormatTest.h +++ b/src/tests/kits/locale/DurationFormatTest.h @@ -15,6 +15,7 @@ public: DurationFormatTest(); virtual ~DurationFormatTest(); + void TestDefault(); void TestDuration(); void TestTimeUnit();