added basic test for wxLocale

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@45082 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Václav Slavík
2007-03-26 21:12:13 +00:00
parent d7a80cf5cd
commit 02f935fbab
11 changed files with 263 additions and 7 deletions

BIN
tests/intl/fr/internat.mo Normal file

Binary file not shown.

77
tests/intl/fr/internat.po Normal file
View File

@@ -0,0 +1,77 @@
# Message catalog file template for the wxWindows i18n sample
# Copyright (C) 1999 wxWindows development team
# Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
#
#: internat.cpp:146
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: wxWindows 2.0 i18n sample\n"
"POT-Creation-Date: 1999-01-13 18:19+0100\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=iso-8859-1\n"
"Content-Transfer-Encoding: 8bit\n"
#: internat.cpp:98
msgid "International wxWindows App"
msgstr "Application wxWindows internationale"
#: internat.cpp:105
msgid "&About..."
msgstr "&A propos..."
#: internat.cpp:107
msgid "E&xit"
msgstr "&Quitter"
#: internat.cpp:110
msgid "&Open bogus file"
msgstr "&Ouvrir un fichier"
#: internat.cpp:111
msgid "&Play a game"
msgstr "&Jouer"
#: internat.cpp:114
msgid "&File"
msgstr "&Fichier"
#: internat.cpp:115
msgid "&Test"
msgstr "&Test"
#: internat.cpp:138
msgid "I18n sample\n"
"<22> 1998, 1999 Vadim Zeitlin and Julian Smart"
msgstr "Exemple d'i18n\n"
"<22> 1998, 1999 Vadim Zeitlin et Julian Smart"
#: internat.cpp:139
msgid "About Internat"
msgstr "A propos d'Internat"
#: internat.cpp:144
msgid "Enter your number:"
msgstr "Entrez votre num<75>ro:"
#: internat.cpp:145
msgid "Try to guess my number!"
msgstr "Essayez de d<>viner mon num<75>ro!"
#: internat.cpp:150
msgid "You've probably entered an invalid number."
msgstr "Vous avez probablement entr<74> un nombre invalide."
#: internat.cpp:154
msgid "Bad luck! try again..."
msgstr "Pas de chance! essayez encore..."
#: internat.cpp:158
msgid "Congratulations! you've won. Here is the magic phrase:"
msgstr "F<>licitations! vouz avez gagn<67>. Voil<69> la phrase magique:"
#: internat.cpp:162
msgid "Result"
msgstr "Resultat"

117
tests/intl/intltest.cpp Normal file
View File

@@ -0,0 +1,117 @@
///////////////////////////////////////////////////////////////////////////////
// Name: tests/intl/intltest.cpp
// Purpose: wxLocale unit test
// Author: Vaclav Slavik
// Created: 2007-03-26
// RCS-ID: $Id$
// Copyright: (c) 2007 Vaclav Slavik
///////////////////////////////////////////////////////////////////////////////
// ----------------------------------------------------------------------------
// headers
// ----------------------------------------------------------------------------
#include "testprec.h"
#ifdef __BORLANDC__
#pragma hdrstop
#endif
#ifndef WX_PRECOMP
#include "wx/wx.h"
#endif // WX_PRECOMP
#include "wx/intl.h"
#if wxUSE_INTL
// ----------------------------------------------------------------------------
// test class
// ----------------------------------------------------------------------------
class IntlTestCase : public CppUnit::TestCase
{
public:
IntlTestCase() {}
virtual void setUp();
virtual void tearDown();
private:
CPPUNIT_TEST_SUITE( IntlTestCase );
CPPUNIT_TEST( Domain );
CPPUNIT_TEST( Headers );
CPPUNIT_TEST_SUITE_END();
void Domain();
void Headers();
wxLocale *m_locale;
DECLARE_NO_COPY_CLASS(IntlTestCase)
};
// register in the unnamed registry so that these tests are run by default
CPPUNIT_TEST_SUITE_REGISTRATION( IntlTestCase );
// also include in it's own registry so that these tests can be run alone
CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( IntlTestCase, "IntlTestCase" );
void IntlTestCase::setUp()
{
wxLocale::AddCatalogLookupPathPrefix("./intl");
m_locale = new wxLocale;
// don't load default catalog, it may be unavailable:
bool loaded = m_locale->Init(wxLANGUAGE_FRENCH, wxLOCALE_CONV_ENCODING);
CPPUNIT_ASSERT( loaded );
m_locale->AddCatalog("internat");
}
void IntlTestCase::tearDown()
{
delete m_locale;
m_locale = NULL;
}
void IntlTestCase::Domain()
{
// _() searches all domains by default:
CPPUNIT_ASSERT( _("&Open bogus file") == "&Ouvrir un fichier" );
// search in our domain only:
CPPUNIT_ASSERT( wxGetTranslation("&Open bogus file", "internat") ==
"&Ouvrir un fichier" );
// search in a domain that doesn't have this string:
CPPUNIT_ASSERT( wxGetTranslation("&Open bogus file", "BogusDomain") ==
"&Open bogus file" );
}
void IntlTestCase::Headers()
{
CPPUNIT_ASSERT( m_locale->GetHeaderValue("Project-Id-Version") ==
"wxWindows 2.0 i18n sample" );
CPPUNIT_ASSERT( m_locale->GetHeaderValue("POT-Creation-Date") ==
"1999-01-13 18:19+0100" );
CPPUNIT_ASSERT( m_locale->GetHeaderValue("PO-Revision-Date") ==
"YEAR-MO-DA HO:MI+ZONE" );
CPPUNIT_ASSERT( m_locale->GetHeaderValue("Last-Translator") ==
"Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>" );
CPPUNIT_ASSERT( m_locale->GetHeaderValue("MIME-Version") ==
"1.0" );
CPPUNIT_ASSERT( m_locale->GetHeaderValue("Content-Type") ==
"text/plain; charset=iso-8859-1" );
CPPUNIT_ASSERT( m_locale->GetHeaderValue("Content-Transfer-Encoding") ==
"8bit" );
// check that it fails with a bogus domain:
CPPUNIT_ASSERT( m_locale->GetHeaderValue("POT-Creation-Date", "Bogus") ==
"" );
// and that it fails for nonexisting header:
CPPUNIT_ASSERT( m_locale->GetHeaderValue("X-Not-Here") == "" );
}
#endif // wxUSE_INTL