]> git.saurik.com Git - wxWidgets.git/blame - tests/intl/intltest.cpp
bracketing opengl code that doesn't work on OpenGL ES
[wxWidgets.git] / tests / intl / intltest.cpp
CommitLineData
02f935fb
VS
1///////////////////////////////////////////////////////////////////////////////
2// Name: tests/intl/intltest.cpp
3// Purpose: wxLocale unit test
4// Author: Vaclav Slavik
5// Created: 2007-03-26
6// RCS-ID: $Id$
7// Copyright: (c) 2007 Vaclav Slavik
8///////////////////////////////////////////////////////////////////////////////
9
10// ----------------------------------------------------------------------------
11// headers
12// ----------------------------------------------------------------------------
13
14#include "testprec.h"
15
16#ifdef __BORLANDC__
17 #pragma hdrstop
18#endif
19
20#ifndef WX_PRECOMP
21 #include "wx/wx.h"
22#endif // WX_PRECOMP
23
24#include "wx/intl.h"
25
26#if wxUSE_INTL
27
28// ----------------------------------------------------------------------------
29// test class
30// ----------------------------------------------------------------------------
31
32class IntlTestCase : public CppUnit::TestCase
33{
34public:
7ab4bb30 35 IntlTestCase() { m_locale=NULL; }
02f935fb
VS
36
37 virtual void setUp();
38 virtual void tearDown();
39
40private:
41 CPPUNIT_TEST_SUITE( IntlTestCase );
42 CPPUNIT_TEST( Domain );
43 CPPUNIT_TEST( Headers );
44 CPPUNIT_TEST_SUITE_END();
45
46 void Domain();
47 void Headers();
48
49 wxLocale *m_locale;
50
51 DECLARE_NO_COPY_CLASS(IntlTestCase)
52};
53
54// register in the unnamed registry so that these tests are run by default
55CPPUNIT_TEST_SUITE_REGISTRATION( IntlTestCase );
56
57// also include in it's own registry so that these tests can be run alone
58CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( IntlTestCase, "IntlTestCase" );
59
60void IntlTestCase::setUp()
61{
7ab4bb30
FM
62 if (!wxLocale::IsAvailable(wxLANGUAGE_FRENCH))
63 return; // you should have french support installed to run this test!
64
02f935fb
VS
65 wxLocale::AddCatalogLookupPathPrefix("./intl");
66
67 m_locale = new wxLocale;
7ab4bb30
FM
68 CPPUNIT_ASSERT( m_locale);
69
02f935fb
VS
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 );
73
74 m_locale->AddCatalog("internat");
75}
76
77void IntlTestCase::tearDown()
78{
7ab4bb30
FM
79 if (m_locale)
80 {
81 delete m_locale;
82 m_locale = NULL;
83 }
02f935fb
VS
84}
85
86void IntlTestCase::Domain()
87{
7ab4bb30
FM
88 if (!m_locale)
89 return; // no french support installed on this system!
90
02f935fb 91 // _() searches all domains by default:
1de532f5 92 CPPUNIT_ASSERT_EQUAL( "&Ouvrir un fichier", _("&Open bogus file") );
02f935fb
VS
93
94 // search in our domain only:
1de532f5 95 CPPUNIT_ASSERT_EQUAL( "&Ouvrir un fichier", wxGetTranslation("&Open bogus file", "internat") );
02f935fb
VS
96
97 // search in a domain that doesn't have this string:
1de532f5 98 CPPUNIT_ASSERT_EQUAL( "&Open bogus file", wxGetTranslation("&Open bogus file", "BogusDomain") );
02f935fb
VS
99}
100
101void IntlTestCase::Headers()
102{
7ab4bb30
FM
103 if (!m_locale)
104 return; // no french support installed on this system!
105
1de532f5
VZ
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") );
02f935fb
VS
113
114 // check that it fails with a bogus domain:
1de532f5 115 CPPUNIT_ASSERT_EQUAL( "", m_locale->GetHeaderValue("POT-Creation-Date", "Bogus") );
02f935fb
VS
116
117 // and that it fails for nonexisting header:
1de532f5 118 CPPUNIT_ASSERT_EQUAL( "", m_locale->GetHeaderValue("X-Not-Here") );
02f935fb
VS
119}
120
121#endif // wxUSE_INTL