]>
git.saurik.com Git - wxWidgets.git/blob - tests/intl/intltest.cpp
097e3a9025a0cff1a86c67eb328c6aa4ea95aafd
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: tests/intl/intltest.cpp
3 // Purpose: wxLocale unit test
4 // Author: Vaclav Slavik
7 // Copyright: (c) 2007 Vaclav Slavik
8 ///////////////////////////////////////////////////////////////////////////////
10 // ----------------------------------------------------------------------------
12 // ----------------------------------------------------------------------------
28 // ----------------------------------------------------------------------------
30 // ----------------------------------------------------------------------------
32 class IntlTestCase
: public CppUnit::TestCase
35 IntlTestCase() { m_locale
=NULL
; }
38 virtual void tearDown();
41 CPPUNIT_TEST_SUITE( IntlTestCase
);
42 CPPUNIT_TEST( Domain
);
43 CPPUNIT_TEST( Headers
);
44 CPPUNIT_TEST_SUITE_END();
51 DECLARE_NO_COPY_CLASS(IntlTestCase
)
54 // register in the unnamed registry so that these tests are run by default
55 CPPUNIT_TEST_SUITE_REGISTRATION( IntlTestCase
);
57 // also include in it's own registry so that these tests can be run alone
58 CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( IntlTestCase
, "IntlTestCase" );
60 void IntlTestCase::setUp()
62 if (!wxLocale::IsAvailable(wxLANGUAGE_FRENCH
))
63 return; // you should have french support installed to run this test!
65 wxLocale::AddCatalogLookupPathPrefix("./intl");
67 m_locale
= new wxLocale
;
68 CPPUNIT_ASSERT( m_locale
);
70 // don't load default catalog, it may be unavailable:
71 bool loaded
= m_locale
->Init(wxLANGUAGE_FRENCH
, wxLOCALE_CONV_ENCODING
);
72 CPPUNIT_ASSERT( loaded
);
74 m_locale
->AddCatalog("internat");
77 void IntlTestCase::tearDown()
86 void IntlTestCase::Domain()
89 return; // no french support installed on this system!
91 // _() searches all domains by default:
92 CPPUNIT_ASSERT_EQUAL( "&Ouvrir un fichier", _("&Open bogus file") );
94 // search in our domain only:
95 CPPUNIT_ASSERT_EQUAL( "&Ouvrir un fichier", wxGetTranslation("&Open bogus file", "internat") );
97 // search in a domain that doesn't have this string:
98 CPPUNIT_ASSERT_EQUAL( "&Open bogus file", wxGetTranslation("&Open bogus file", "BogusDomain") );
101 void IntlTestCase::Headers()
104 return; // no french support installed on this system!
106 CPPUNIT_ASSERT_EQUAL( "wxWindows 2.0 i18n sample", m_locale
->GetHeaderValue("Project-Id-Version") );
107 CPPUNIT_ASSERT_EQUAL( "1999-01-13 18:19+0100", m_locale
->GetHeaderValue("POT-Creation-Date") );
108 CPPUNIT_ASSERT_EQUAL( "YEAR-MO-DA HO:MI+ZONE", m_locale
->GetHeaderValue("PO-Revision-Date") );
109 CPPUNIT_ASSERT_EQUAL( "Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>", m_locale
->GetHeaderValue("Last-Translator") );
110 CPPUNIT_ASSERT_EQUAL( "1.0", m_locale
->GetHeaderValue("MIME-Version") );
111 CPPUNIT_ASSERT_EQUAL( "text/plain; charset=iso-8859-1", m_locale
->GetHeaderValue("Content-Type") );
112 CPPUNIT_ASSERT_EQUAL( "8bit", m_locale
->GetHeaderValue("Content-Transfer-Encoding") );
114 // check that it fails with a bogus domain:
115 CPPUNIT_ASSERT_EQUAL( "", m_locale
->GetHeaderValue("POT-Creation-Date", "Bogus") );
117 // and that it fails for nonexisting header:
118 CPPUNIT_ASSERT_EQUAL( "", m_locale
->GetHeaderValue("X-Not-Here") );