+// ----------------------------------------------------------------------------
+// wxHashTable
+// ----------------------------------------------------------------------------
+
+#ifdef TEST_HASH
+
+#include "wx/hash.h"
+
+struct Foo
+{
+ Foo(int n_) { n = n_; count++; }
+ ~Foo() { count--; }
+
+ int n;
+
+ static size_t count;
+};
+
+size_t Foo::count = 0;
+
+WX_DECLARE_LIST(Foo, wxListFoos);
+WX_DECLARE_HASH(Foo, wxListFoos, wxHashFoos);
+
+#include "wx/listimpl.cpp"
+
+WX_DEFINE_LIST(wxListFoos);
+
+static void TestHash()
+{
+ wxPuts(_T("*** Testing wxHashTable ***\n"));
+
+ {
+ wxHashTable hash(wxKEY_INTEGER, 10), hash2(wxKEY_STRING);
+ wxObject o;
+ int i;
+
+ for ( i = 0; i < 100; ++i )
+ hash.Put(i, &o + i);
+
+ hash.BeginFind();
+ wxHashTable::compatibility_iterator it = hash.Next();
+ i = 0;
+
+ while (it)
+ {
+ ++i;
+ it = hash.Next();
+ }
+
+ if (i != 100)
+ wxPuts(_T("Error in wxHashTable::compatibility_iterator\n"));
+
+ for ( i = 99; i >= 0; --i )
+ if( hash.Get(i) != &o + i )
+ wxPuts(_T("Error in wxHashTable::Get/Put\n"));
+
+ for ( i = 0; i < 100; ++i )
+ hash.Put(i, &o + i + 20);
+
+ for ( i = 99; i >= 0; --i )
+ if( hash.Get(i) != &o + i)
+ wxPuts(_T("Error (2) in wxHashTable::Get/Put\n"));
+
+ for ( i = 0; i < 50; ++i )
+ if( hash.Delete(i) != &o + i)
+ wxPuts(_T("Error in wxHashTable::Delete\n"));
+
+ for ( i = 50; i < 100; ++i )
+ if( hash.Get(i) != &o + i)
+ wxPuts(_T("Error (3) in wxHashTable::Get/Put\n"));
+
+ for ( i = 0; i < 50; ++i )
+ if( hash.Get(i) != &o + i + 20)
+ wxPuts(_T("Error (4) in wxHashTable::Put/Delete\n"));
+
+ for ( i = 0; i < 50; ++i )
+ if( hash.Delete(i) != &o + i + 20)
+ wxPuts(_T("Error (2) in wxHashTable::Delete\n"));
+
+ for ( i = 0; i < 50; ++i )
+ if( hash.Get(i) != NULL)
+ wxPuts(_T("Error (5) in wxHashTable::Put/Delete\n"));
+
+ hash2.Put(_T("foo"), &o + 1);
+ hash2.Put(_T("bar"), &o + 2);
+ hash2.Put(_T("baz"), &o + 3);
+
+ if (hash2.Get(_T("moo")) != NULL)
+ wxPuts(_T("Error in wxHashTable::Get\n"));
+
+ if (hash2.Get(_T("bar")) != &o + 2)
+ wxPuts(_T("Error in wxHashTable::Get/Put\n"));
+
+ hash2.Put(_T("bar"), &o + 0);
+
+ if (hash2.Get(_T("bar")) != &o + 2)
+ wxPuts(_T("Error (2) in wxHashTable::Get/Put\n"));
+ }
+#if !wxUSE_STL
+ {
+ wxHashFoos hash;
+ hash.DeleteContents(true);
+
+ wxPrintf(_T("Hash created: %u foos in hash, %u foos totally\n"),
+ hash.GetCount(), Foo::count);
+
+ static const int hashTestData[] =
+ {
+ 0, 1, 17, -2, 2, 4, -4, 345, 3, 3, 2, 1,
+ };
+
+ size_t n;
+ for ( n = 0; n < WXSIZEOF(hashTestData); n++ )
+ {
+ hash.Put(hashTestData[n], n, new Foo(n));
+ }
+
+ wxPrintf(_T("Hash filled: %u foos in hash, %u foos totally\n"),
+ hash.GetCount(), Foo::count);
+
+ wxPuts(_T("Hash access test:"));
+ for ( n = 0; n < WXSIZEOF(hashTestData); n++ )
+ {
+ wxPrintf(_T("\tGetting element with key %d, value %d: "),
+ hashTestData[n], n);
+ Foo *foo = hash.Get(hashTestData[n], n);
+ if ( !foo )
+ {
+ wxPrintf(_T("ERROR, not found.\n"));
+ }
+ else
+ {
+ wxPrintf(_T("%d (%s)\n"), foo->n,
+ (size_t)foo->n == n ? "ok" : "ERROR");
+ }
+ }
+
+ wxPrintf(_T("\nTrying to get an element not in hash: "));
+
+ if ( hash.Get(1234) || hash.Get(1, 0) )
+ {
+ wxPuts(_T("ERROR: found!"));
+ }
+ else
+ {
+ wxPuts(_T("ok (not found)"));
+ }
+ }
+#endif
+
+ wxPrintf(_T("Hash destroyed: %u foos left\n"), Foo::count);
+ wxPuts(_T("*** Testing wxHashTable finished ***\n"));
+}
+
+#endif // TEST_HASH
+
+// ----------------------------------------------------------------------------
+// wxHashMap
+// ----------------------------------------------------------------------------
+
+#ifdef TEST_HASHMAP
+
+#include "wx/hashmap.h"
+
+// test compilation of basic map types
+WX_DECLARE_HASH_MAP( int*, int*, wxPointerHash, wxPointerEqual, myPtrHashMap );
+WX_DECLARE_HASH_MAP( long, long, wxIntegerHash, wxIntegerEqual, myLongHashMap );
+WX_DECLARE_HASH_MAP( unsigned long, unsigned, wxIntegerHash, wxIntegerEqual,
+ myUnsignedHashMap );
+WX_DECLARE_HASH_MAP( unsigned int, unsigned, wxIntegerHash, wxIntegerEqual,
+ myTestHashMap1 );
+WX_DECLARE_HASH_MAP( int, unsigned, wxIntegerHash, wxIntegerEqual,
+ myTestHashMap2 );
+WX_DECLARE_HASH_MAP( short, unsigned, wxIntegerHash, wxIntegerEqual,
+ myTestHashMap3 );
+WX_DECLARE_HASH_MAP( unsigned short, unsigned, wxIntegerHash, wxIntegerEqual,
+ myTestHashMap4 );
+
+// same as:
+// WX_DECLARE_HASH_MAP( wxString, wxString, wxStringHash, wxStringEqual,
+// myStringHashMap );
+WX_DECLARE_STRING_HASH_MAP(wxString, myStringHashMap);
+
+typedef myStringHashMap::iterator Itor;
+
+static void TestHashMap()
+{
+ wxPuts(_T("*** Testing wxHashMap ***\n"));
+ myStringHashMap sh(0); // as small as possible
+ wxString buf;
+ size_t i;
+ const size_t count = 10000;
+
+ // init with some data
+ for( i = 0; i < count; ++i )
+ {
+ buf.Printf(wxT("%d"), i );
+ sh[buf] = wxT("A") + buf + wxT("C");
+ }
+
+ // test that insertion worked
+ if( sh.size() != count )
+ {
+ wxPrintf(_T("*** ERROR: %u ELEMENTS, SHOULD BE %u ***\n"), sh.size(), count);
+ }
+
+ for( i = 0; i < count; ++i )
+ {
+ buf.Printf(wxT("%d"), i );
+ if( sh[buf] != wxT("A") + buf + wxT("C") )
+ {
+ wxPrintf(_T("*** ERROR INSERTION BROKEN! STOPPING NOW! ***\n"));
+ return;
+ }
+ }
+
+ // check that iterators work
+ Itor it;
+ for( i = 0, it = sh.begin(); it != sh.end(); ++it, ++i )
+ {
+ if( i == count )
+ {
+ wxPrintf(_T("*** ERROR ITERATORS DO NOT TERMINATE! STOPPING NOW! ***\n"));
+ return;
+ }
+
+ if( it->second != sh[it->first] )
+ {
+ wxPrintf(_T("*** ERROR ITERATORS BROKEN! STOPPING NOW! ***\n"));
+ return;
+ }
+ }
+
+ if( sh.size() != i )
+ {
+ wxPrintf(_T("*** ERROR: %u ELEMENTS ITERATED, SHOULD BE %u ***\n"), i, count);
+ }
+
+ // test copy ctor, assignment operator
+ myStringHashMap h1( sh ), h2( 0 );
+ h2 = sh;
+
+ for( i = 0, it = sh.begin(); it != sh.end(); ++it, ++i )
+ {
+ if( h1[it->first] != it->second )
+ {
+ wxPrintf(_T("*** ERROR: COPY CTOR BROKEN %s ***\n"), it->first.c_str());
+ }
+
+ if( h2[it->first] != it->second )
+ {
+ wxPrintf(_T("*** ERROR: OPERATOR= BROKEN %s ***\n"), it->first.c_str());
+ }
+ }
+
+ // other tests
+ for( i = 0; i < count; ++i )
+ {
+ buf.Printf(wxT("%d"), i );
+ size_t sz = sh.size();
+
+ // test find() and erase(it)
+ if( i < 100 )
+ {
+ it = sh.find( buf );
+ if( it != sh.end() )
+ {
+ sh.erase( it );
+
+ if( sh.find( buf ) != sh.end() )
+ {
+ wxPrintf(_T("*** ERROR: FOUND DELETED ELEMENT %u ***\n"), i);
+ }
+ }
+ else
+ wxPrintf(_T("*** ERROR: CANT FIND ELEMENT %u ***\n"), i);
+ }
+ else
+ // test erase(key)
+ {
+ size_t c = sh.erase( buf );
+ if( c != 1 )
+ wxPrintf(_T("*** ERROR: SHOULD RETURN 1 ***\n"));
+
+ if( sh.find( buf ) != sh.end() )
+ {
+ wxPrintf(_T("*** ERROR: FOUND DELETED ELEMENT %u ***\n"), i);
+ }
+ }
+
+ // count should decrease
+ if( sh.size() != sz - 1 )
+ {
+ wxPrintf(_T("*** ERROR: COUNT DID NOT DECREASE ***\n"));
+ }
+ }
+
+ wxPrintf(_T("*** Finished testing wxHashMap ***\n"));
+}
+
+#endif // TEST_HASHMAP
+
+// ----------------------------------------------------------------------------
+// wxHashSet
+// ----------------------------------------------------------------------------
+
+#ifdef TEST_HASHSET
+
+#include "wx/hashset.h"
+
+// test compilation of basic map types
+WX_DECLARE_HASH_SET( int*, wxPointerHash, wxPointerEqual, myPtrHashSet );
+WX_DECLARE_HASH_SET( long, wxIntegerHash, wxIntegerEqual, myLongHashSet );
+WX_DECLARE_HASH_SET( unsigned long, wxIntegerHash, wxIntegerEqual,
+ myUnsignedHashSet );
+WX_DECLARE_HASH_SET( unsigned int, wxIntegerHash, wxIntegerEqual,
+ myTestHashSet1 );
+WX_DECLARE_HASH_SET( int, wxIntegerHash, wxIntegerEqual,
+ myTestHashSet2 );
+WX_DECLARE_HASH_SET( short, wxIntegerHash, wxIntegerEqual,
+ myTestHashSet3 );
+WX_DECLARE_HASH_SET( unsigned short, wxIntegerHash, wxIntegerEqual,
+ myTestHashSet4 );
+WX_DECLARE_HASH_SET( wxString, wxStringHash, wxStringEqual,
+ myTestHashSet5 );
+
+struct MyStruct
+{
+ int* ptr;
+ wxString str;
+};
+
+class MyHash
+{
+public:
+ unsigned long operator()(const MyStruct& s) const
+ { return m_dummy(s.ptr); }
+ MyHash& operator=(const MyHash&) { return *this; }
+private:
+ wxPointerHash m_dummy;
+};
+
+class MyEqual
+{
+public:
+ bool operator()(const MyStruct& s1, const MyStruct& s2) const
+ { return s1.ptr == s2.ptr; }
+ MyEqual& operator=(const MyEqual&) { return *this; }
+};
+
+WX_DECLARE_HASH_SET( MyStruct, MyHash, MyEqual, mySet );
+
+typedef myTestHashSet5 wxStringHashSet;
+
+static void TestHashSet()
+{
+ wxPrintf(_T("*** Testing wxHashSet ***\n"));
+
+ wxStringHashSet set1;
+
+ set1.insert( _T("abc") );
+ set1.insert( _T("bbc") );
+ set1.insert( _T("cbc") );
+ set1.insert( _T("abc") );
+
+ if( set1.size() != 3 )
+ wxPrintf(_T("*** ERROR IN INSERT ***\n"));
+
+ mySet set2;
+ int dummy;
+ MyStruct tmp;
+
+ tmp.ptr = &dummy; tmp.str = _T("ABC");
+ set2.insert( tmp );
+ tmp.ptr = &dummy + 1;
+ set2.insert( tmp );
+ tmp.ptr = &dummy; tmp.str = _T("CDE");
+ set2.insert( tmp );
+
+ if( set2.size() != 2 )
+ wxPrintf(_T("*** ERROR IN INSERT - 2 ***\n"));
+
+ mySet::iterator it = set2.find( tmp );
+
+ if( it == set2.end() )
+ wxPrintf(_T("*** ERROR IN FIND - 1 ***\n"));
+ if( it->ptr != &dummy )
+ wxPrintf(_T("*** ERROR IN FIND - 2 ***\n"));
+ if( it->str != _T("ABC") )
+ wxPrintf(_T("*** ERROR IN INSERT - 3 ***\n"));
+
+ wxPrintf(_T("*** Finished testing wxHashSet ***\n"));
+}
+
+#endif // TEST_HASHSET
+
+// ----------------------------------------------------------------------------
+// wxList
+// ----------------------------------------------------------------------------
+
+#ifdef TEST_LIST
+
+#include "wx/list.h"
+
+WX_DECLARE_LIST(Bar, wxListBars);
+#include "wx/listimpl.cpp"
+WX_DEFINE_LIST(wxListBars);
+
+WX_DECLARE_LIST(int, wxListInt);
+WX_DEFINE_LIST(wxListInt);
+
+static void TestList()
+{
+ wxPuts(_T("*** Testing wxList operations ***\n"));
+ {
+ wxListInt list1;
+ int dummy[5];
+ int i;
+
+ for ( i = 0; i < 5; ++i )
+ list1.Append(dummy + i);
+
+ if ( list1.GetCount() != 5 )
+ wxPuts(_T("Wrong number of items in list\n"));
+
+ if ( list1.Item(3)->GetData() != dummy + 3 )
+ wxPuts(_T("Error in Item()\n"));
+
+ if ( !list1.Find(dummy + 4) )
+ wxPuts(_T("Error in Find()\n"));
+
+ wxListInt::compatibility_iterator node = list1.GetFirst();
+ i = 0;
+
+ while (node)
+ {
+ if ( node->GetData() != dummy + i )
+ wxPuts(_T("Error in compatibility_iterator\n"));
+ node = node->GetNext();
+ ++i;
+ }
+
+ if ( size_t(i) != list1.GetCount() )
+ wxPuts(_T("Error in compatibility_iterator\n"));
+
+ list1.Insert(dummy + 0);
+ list1.Insert(1, dummy + 1);
+ list1.Insert(list1.GetFirst()->GetNext()->GetNext(), dummy + 2);
+
+ node = list1.GetFirst();
+ i = 0;
+
+ while (i < 3)
+ {
+ int* t = node->GetData();
+ if ( t != dummy + i )
+ wxPuts(_T("Error in Insert\n"));
+ node = node->GetNext();
+ ++i;
+ }
+ }
+
+ wxPuts(_T("*** Testing wxList operations finished ***\n"));
+
+ wxPuts(_T("*** Testing std::list operations ***\n"));
+
+ {
+ wxListInt list1;
+ wxListInt::iterator it, en;
+ wxListInt::reverse_iterator rit, ren;
+ int i;
+ for ( i = 0; i < 5; ++i )
+ list1.push_back(i + &i);
+
+ for ( it = list1.begin(), en = list1.end(), i = 0;
+ it != en; ++it, ++i )
+ if ( *it != i + &i )
+ wxPuts(_T("Error in iterator\n"));
+
+ for ( rit = list1.rbegin(), ren = list1.rend(), i = 4;
+ rit != ren; ++rit, --i )
+ if ( *rit != i + &i )
+ wxPuts(_T("Error in reverse_iterator\n"));
+
+ if ( *list1.rbegin() != *--list1.end() ||
+ *list1.begin() != *--list1.rend() )
+ wxPuts(_T("Error in iterator/reverse_iterator\n"));
+ if ( *list1.begin() != *--++list1.begin() ||
+ *list1.rbegin() != *--++list1.rbegin() )
+ wxPuts(_T("Error in iterator/reverse_iterator\n"));
+
+ if ( list1.front() != &i || list1.back() != &i + 4 )
+ wxPuts(_T("Error in front()/back()\n"));
+
+ list1.erase(list1.begin());
+ list1.erase(--list1.end());
+
+ for ( it = list1.begin(), en = list1.end(), i = 1;
+ it != en; ++it, ++i )
+ if ( *it != i + &i )
+ wxPuts(_T("Error in erase()\n"));
+ }
+
+ wxPuts(_T("*** Testing std::list operations finished ***\n"));
+}
+
+static void TestListCtor()
+{
+ wxPuts(_T("*** Testing wxList construction ***\n"));
+
+ {
+ wxListBars list1;
+ list1.Append(new Bar(_T("first")));
+ list1.Append(new Bar(_T("second")));
+
+ wxPrintf(_T("After 1st list creation: %u objects in the list, %u objects total.\n"),
+ list1.GetCount(), Bar::GetNumber());
+
+ wxListBars list2;
+ list2 = list1;
+
+ wxPrintf(_T("After 2nd list creation: %u and %u objects in the lists, %u objects total.\n"),
+ list1.GetCount(), list2.GetCount(), Bar::GetNumber());
+
+#if !wxUSE_STL
+ list1.DeleteContents(true);
+#else
+ WX_CLEAR_LIST(wxListBars, list1);
+#endif
+ }
+
+ wxPrintf(_T("After list destruction: %u objects left.\n"), Bar::GetNumber());
+}
+
+#endif // TEST_LIST
+
+// ----------------------------------------------------------------------------
+// wxLocale
+// ----------------------------------------------------------------------------
+
+#ifdef TEST_LOCALE
+
+#include "wx/intl.h"
+#include "wx/utils.h" // for wxSetEnv
+
+static wxLocale gs_localeDefault(wxLANGUAGE_ENGLISH);
+
+// find the name of the language from its value
+static const wxChar *GetLangName(int lang)
+{
+ static const wxChar *languageNames[] =
+ {
+ _T("DEFAULT"),
+ _T("UNKNOWN"),
+ _T("ABKHAZIAN"),
+ _T("AFAR"),
+ _T("AFRIKAANS"),
+ _T("ALBANIAN"),
+ _T("AMHARIC"),
+ _T("ARABIC"),
+ _T("ARABIC_ALGERIA"),
+ _T("ARABIC_BAHRAIN"),
+ _T("ARABIC_EGYPT"),
+ _T("ARABIC_IRAQ"),
+ _T("ARABIC_JORDAN"),
+ _T("ARABIC_KUWAIT"),
+ _T("ARABIC_LEBANON"),
+ _T("ARABIC_LIBYA"),
+ _T("ARABIC_MOROCCO"),
+ _T("ARABIC_OMAN"),
+ _T("ARABIC_QATAR"),
+ _T("ARABIC_SAUDI_ARABIA"),
+ _T("ARABIC_SUDAN"),
+ _T("ARABIC_SYRIA"),
+ _T("ARABIC_TUNISIA"),
+ _T("ARABIC_UAE"),
+ _T("ARABIC_YEMEN"),
+ _T("ARMENIAN"),
+ _T("ASSAMESE"),
+ _T("AYMARA"),
+ _T("AZERI"),
+ _T("AZERI_CYRILLIC"),
+ _T("AZERI_LATIN"),
+ _T("BASHKIR"),
+ _T("BASQUE"),
+ _T("BELARUSIAN"),
+ _T("BENGALI"),
+ _T("BHUTANI"),
+ _T("BIHARI"),
+ _T("BISLAMA"),
+ _T("BRETON"),
+ _T("BULGARIAN"),
+ _T("BURMESE"),
+ _T("CAMBODIAN"),
+ _T("CATALAN"),
+ _T("CHINESE"),
+ _T("CHINESE_SIMPLIFIED"),
+ _T("CHINESE_TRADITIONAL"),
+ _T("CHINESE_HONGKONG"),
+ _T("CHINESE_MACAU"),
+ _T("CHINESE_SINGAPORE"),
+ _T("CHINESE_TAIWAN"),
+ _T("CORSICAN"),
+ _T("CROATIAN"),
+ _T("CZECH"),
+ _T("DANISH"),
+ _T("DUTCH"),
+ _T("DUTCH_BELGIAN"),
+ _T("ENGLISH"),
+ _T("ENGLISH_UK"),
+ _T("ENGLISH_US"),
+ _T("ENGLISH_AUSTRALIA"),
+ _T("ENGLISH_BELIZE"),
+ _T("ENGLISH_BOTSWANA"),
+ _T("ENGLISH_CANADA"),
+ _T("ENGLISH_CARIBBEAN"),
+ _T("ENGLISH_DENMARK"),
+ _T("ENGLISH_EIRE"),
+ _T("ENGLISH_JAMAICA"),
+ _T("ENGLISH_NEW_ZEALAND"),
+ _T("ENGLISH_PHILIPPINES"),
+ _T("ENGLISH_SOUTH_AFRICA"),
+ _T("ENGLISH_TRINIDAD"),
+ _T("ENGLISH_ZIMBABWE"),
+ _T("ESPERANTO"),
+ _T("ESTONIAN"),
+ _T("FAEROESE"),
+ _T("FARSI"),
+ _T("FIJI"),
+ _T("FINNISH"),
+ _T("FRENCH"),
+ _T("FRENCH_BELGIAN"),
+ _T("FRENCH_CANADIAN"),
+ _T("FRENCH_LUXEMBOURG"),
+ _T("FRENCH_MONACO"),
+ _T("FRENCH_SWISS"),
+ _T("FRISIAN"),
+ _T("GALICIAN"),
+ _T("GEORGIAN"),
+ _T("GERMAN"),
+ _T("GERMAN_AUSTRIAN"),
+ _T("GERMAN_BELGIUM"),
+ _T("GERMAN_LIECHTENSTEIN"),
+ _T("GERMAN_LUXEMBOURG"),
+ _T("GERMAN_SWISS"),
+ _T("GREEK"),
+ _T("GREENLANDIC"),
+ _T("GUARANI"),
+ _T("GUJARATI"),
+ _T("HAUSA"),
+ _T("HEBREW"),
+ _T("HINDI"),
+ _T("HUNGARIAN"),
+ _T("ICELANDIC"),
+ _T("INDONESIAN"),
+ _T("INTERLINGUA"),
+ _T("INTERLINGUE"),
+ _T("INUKTITUT"),
+ _T("INUPIAK"),
+ _T("IRISH"),
+ _T("ITALIAN"),
+ _T("ITALIAN_SWISS"),
+ _T("JAPANESE"),
+ _T("JAVANESE"),
+ _T("KANNADA"),
+ _T("KASHMIRI"),
+ _T("KASHMIRI_INDIA"),
+ _T("KAZAKH"),
+ _T("KERNEWEK"),
+ _T("KINYARWANDA"),
+ _T("KIRGHIZ"),
+ _T("KIRUNDI"),
+ _T("KONKANI"),
+ _T("KOREAN"),
+ _T("KURDISH"),
+ _T("LAOTHIAN"),
+ _T("LATIN"),
+ _T("LATVIAN"),
+ _T("LINGALA"),
+ _T("LITHUANIAN"),
+ _T("MACEDONIAN"),
+ _T("MALAGASY"),
+ _T("MALAY"),
+ _T("MALAYALAM"),
+ _T("MALAY_BRUNEI_DARUSSALAM"),
+ _T("MALAY_MALAYSIA"),
+ _T("MALTESE"),
+ _T("MANIPURI"),
+ _T("MAORI"),
+ _T("MARATHI"),
+ _T("MOLDAVIAN"),
+ _T("MONGOLIAN"),
+ _T("NAURU"),
+ _T("NEPALI"),
+ _T("NEPALI_INDIA"),
+ _T("NORWEGIAN_BOKMAL"),
+ _T("NORWEGIAN_NYNORSK"),
+ _T("OCCITAN"),
+ _T("ORIYA"),
+ _T("OROMO"),
+ _T("PASHTO"),
+ _T("POLISH"),
+ _T("PORTUGUESE"),
+ _T("PORTUGUESE_BRAZILIAN"),
+ _T("PUNJABI"),
+ _T("QUECHUA"),
+ _T("RHAETO_ROMANCE"),
+ _T("ROMANIAN"),
+ _T("RUSSIAN"),
+ _T("RUSSIAN_UKRAINE"),
+ _T("SAMOAN"),
+ _T("SANGHO"),
+ _T("SANSKRIT"),
+ _T("SCOTS_GAELIC"),
+ _T("SERBIAN"),
+ _T("SERBIAN_CYRILLIC"),
+ _T("SERBIAN_LATIN"),
+ _T("SERBO_CROATIAN"),
+ _T("SESOTHO"),
+ _T("SETSWANA"),
+ _T("SHONA"),
+ _T("SINDHI"),
+ _T("SINHALESE"),
+ _T("SISWATI"),
+ _T("SLOVAK"),
+ _T("SLOVENIAN"),
+ _T("SOMALI"),
+ _T("SPANISH"),
+ _T("SPANISH_ARGENTINA"),
+ _T("SPANISH_BOLIVIA"),
+ _T("SPANISH_CHILE"),
+ _T("SPANISH_COLOMBIA"),
+ _T("SPANISH_COSTA_RICA"),
+ _T("SPANISH_DOMINICAN_REPUBLIC"),
+ _T("SPANISH_ECUADOR"),
+ _T("SPANISH_EL_SALVADOR"),
+ _T("SPANISH_GUATEMALA"),
+ _T("SPANISH_HONDURAS"),
+ _T("SPANISH_MEXICAN"),
+ _T("SPANISH_MODERN"),
+ _T("SPANISH_NICARAGUA"),
+ _T("SPANISH_PANAMA"),
+ _T("SPANISH_PARAGUAY"),
+ _T("SPANISH_PERU"),
+ _T("SPANISH_PUERTO_RICO"),
+ _T("SPANISH_URUGUAY"),
+ _T("SPANISH_US"),
+ _T("SPANISH_VENEZUELA"),
+ _T("SUNDANESE"),
+ _T("SWAHILI"),
+ _T("SWEDISH"),
+ _T("SWEDISH_FINLAND"),
+ _T("TAGALOG"),
+ _T("TAJIK"),
+ _T("TAMIL"),
+ _T("TATAR"),
+ _T("TELUGU"),
+ _T("THAI"),
+ _T("TIBETAN"),
+ _T("TIGRINYA"),
+ _T("TONGA"),
+ _T("TSONGA"),
+ _T("TURKISH"),
+ _T("TURKMEN"),
+ _T("TWI"),
+ _T("UIGHUR"),
+ _T("UKRAINIAN"),
+ _T("URDU"),
+ _T("URDU_INDIA"),
+ _T("URDU_PAKISTAN"),
+ _T("UZBEK"),
+ _T("UZBEK_CYRILLIC"),
+ _T("UZBEK_LATIN"),
+ _T("VIETNAMESE"),
+ _T("VOLAPUK"),
+ _T("WELSH"),
+ _T("WOLOF"),
+ _T("XHOSA"),
+ _T("YIDDISH"),
+ _T("YORUBA"),
+ _T("ZHUANG"),
+ _T("ZULU"),
+ };
+
+ if ( (size_t)lang < WXSIZEOF(languageNames) )
+ return languageNames[lang];
+ else
+ return _T("INVALID");
+}
+
+static void TestDefaultLang()
+{
+ wxPuts(_T("*** Testing wxLocale::GetSystemLanguage ***"));
+
+ static const wxChar *langStrings[] =
+ {
+ NULL, // system default
+ _T("C"),
+ _T("fr"),
+ _T("fr_FR"),
+ _T("en"),
+ _T("en_GB"),
+ _T("en_US"),
+ _T("de_DE.iso88591"),
+ _T("german"),
+ _T("?"), // invalid lang spec
+ _T("klingonese"), // I bet on some systems it does exist...
+ };
+
+ wxPrintf(_T("The default system encoding is %s (%d)\n"),
+ wxLocale::GetSystemEncodingName().c_str(),
+ wxLocale::GetSystemEncoding());
+
+ for ( size_t n = 0; n < WXSIZEOF(langStrings); n++ )
+ {
+ const wxChar *langStr = langStrings[n];
+ if ( langStr )
+ {
+ // FIXME: this doesn't do anything at all under Windows, we need
+ // to create a new wxLocale!
+ wxSetEnv(_T("LC_ALL"), langStr);
+ }
+
+ int lang = gs_localeDefault.GetSystemLanguage();
+ wxPrintf(_T("Locale for '%s' is %s.\n"),
+ langStr ? langStr : _T("system default"), GetLangName(lang));
+ }
+}
+
+#endif // TEST_LOCALE
+
+// ----------------------------------------------------------------------------
+// MIME types
+// ----------------------------------------------------------------------------
+
+#ifdef TEST_MIME
+
+#include "wx/mimetype.h"
+
+static void TestMimeEnum()
+{
+ wxPuts(_T("*** Testing wxMimeTypesManager::EnumAllFileTypes() ***\n"));
+
+ wxArrayString mimetypes;
+
+ size_t count = wxTheMimeTypesManager->EnumAllFileTypes(mimetypes);
+
+ wxPrintf(_T("*** All %u known filetypes: ***\n"), count);