diff --git a/livesupport/modules/core/src/LocalizedObjectTest.cxx b/livesupport/modules/core/src/LocalizedObjectTest.cxx index 4134a39ec..71fa09303 100644 --- a/livesupport/modules/core/src/LocalizedObjectTest.cxx +++ b/livesupport/modules/core/src/LocalizedObjectTest.cxx @@ -22,7 +22,7 @@ Author : $Author: maroy $ - Version : $Revision: 1.4 $ + Version : $Revision: 1.5 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/core/src/LocalizedObjectTest.cxx,v $ ------------------------------------------------------------------------------*/ @@ -308,3 +308,33 @@ LocalizedObjectTest :: ustringTest(void) } +/*------------------------------------------------------------------------------ + * Test the ustring related functions in problematic situations + * see http://bugs.campware.org/view.php?id=792 + *----------------------------------------------------------------------------*/ +void +LocalizedObjectTest :: ustringNegativeTest(void) + throw (CPPUNIT_NS::Exception) +{ + bool gotException; + UErrorCode status = U_ZERO_ERROR; + Ptr::Ref bundle(new ResourceBundle("./tmp/" PACKAGE_NAME, + "root", + status)); + CPPUNIT_ASSERT(U_SUCCESS(status)); + + // test getting a missing ustring resource + gotException = false; + try { + Ptr::Ref locObj(new LocalizedObject(bundle)); + Ptr::Ref section1(new LocalizedObject( + locObj->getBundle("section1"))); + Ptr::Ref foo = + section1->getResourceUstring("nonexistentKey"); + } catch (std::invalid_argument &e) { + gotException = true; + } + CPPUNIT_ASSERT(gotException); +} + + diff --git a/livesupport/modules/core/src/LocalizedObjectTest.h b/livesupport/modules/core/src/LocalizedObjectTest.h index 86552d842..d46ecbfc7 100644 --- a/livesupport/modules/core/src/LocalizedObjectTest.h +++ b/livesupport/modules/core/src/LocalizedObjectTest.h @@ -22,7 +22,7 @@ Author : $Author: maroy $ - Version : $Revision: 1.4 $ + Version : $Revision: 1.5 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/core/src/LocalizedObjectTest.h,v $ ------------------------------------------------------------------------------*/ @@ -58,7 +58,7 @@ namespace Core { * Unit test for the LocalizedObject class. * * @author $Author: maroy $ - * @version $Revision: 1.4 $ + * @version $Revision: 1.5 $ * @see LocalizedObject */ class LocalizedObjectTest : public CPPUNIT_NS::TestFixture @@ -70,6 +70,7 @@ class LocalizedObjectTest : public CPPUNIT_NS::TestFixture CPPUNIT_TEST(formatMessageTest); CPPUNIT_TEST(loadFromConfigTest); CPPUNIT_TEST(ustringTest); + CPPUNIT_TEST(ustringNegativeTest); CPPUNIT_TEST_SUITE_END(); protected: @@ -124,6 +125,15 @@ class LocalizedObjectTest : public CPPUNIT_NS::TestFixture void ustringTest(void) throw (CPPUNIT_NS::Exception); + /** + * A test to check the Glib::ustring related function beaviour + * in problematic situations. + * + * @exception CPPUNIT_NS::Exception on test failures. + */ + void + ustringNegativeTest(void) throw (CPPUNIT_NS::Exception); + public: