- printf("Hash filled: %u foos in hash, %u foos totally\n",
- hash.GetCount(), Foo::count);
-
- puts("Hash access test:");
- for ( n = 0; n < WXSIZEOF(hashTestData); n++ )
- {
- printf("\tGetting element with key %d, value %d: ",
- hashTestData[n], n);
- Foo *foo = hash.Get(hashTestData[n], n);
- if ( !foo )
- {
- printf("ERROR, not found.\n");
- }
- else
- {
- printf("%d (%s)\n", foo->n,
- (size_t)foo->n == n ? "ok" : "ERROR");
- }
- }
-
- printf("\nTrying to get an element not in hash: ");
-
- if ( hash.Get(1234) || hash.Get(1, 0) )
- {
- puts("ERROR: found!");
- }
- else
- {
- puts("ok (not found)");
- }
- }
-
- printf("Hash destroyed: %u foos left\n", Foo::count);
-}
-
-#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()
-{
- puts("*** 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 )
- {
- printf("*** 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") )
- {
- printf("*** 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 )
- {
- printf("*** ERROR ITERATORS DO NOT TERMINATE! STOPPING NOW! ***\n");
- return;
- }
-
- if( it->second != sh[it->first] )
- {
- printf("*** ERROR ITERATORS BROKEN! STOPPING NOW! ***\n");
- return;
- }
- }
-
- if( sh.size() != i )
- {
- printf("*** 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 )
- {
- printf("*** ERROR: COPY CTOR BROKEN %s ***\n", it->first.c_str());
- }
-
- if( h2[it->first] != it->second )
- {
- printf("*** 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() )
- {
- printf("*** ERROR: FOUND DELETED ELEMENT %u ***\n", i);
- }
- }
- else
- printf("*** ERROR: CANT FIND ELEMENT %u ***\n", i);
- }
- else
- // test erase(key)
- {
- size_t c = sh.erase( buf );
- if( c != 1 )
- printf("*** ERROR: SHOULD RETURN 1 ***\n");
-
- if( sh.find( buf ) != sh.end() )
- {
- printf("*** ERROR: FOUND DELETED ELEMENT %u ***\n", i);
- }
- }
-
- // count should decrease
- if( sh.size() != sz - 1 )
- {
- printf("*** ERROR: COUNT DID NOT DECREASE ***\n");
- }
- }
-
- printf("*** Finished testing wxHashMap ***\n");
-}
-
-#endif // TEST_HASHMAP
-
-// ----------------------------------------------------------------------------
-// wxList
-// ----------------------------------------------------------------------------
-
-#ifdef TEST_LIST
-
-#include "wx/list.h"
-
-WX_DECLARE_LIST(Bar, wxListBars);
-#include "wx/listimpl.cpp"
-WX_DEFINE_LIST(wxListBars);
-
-static void TestListCtor()
-{
- puts("*** Testing wxList construction ***\n");
-
- {
- wxListBars list1;
- list1.Append(new Bar(_T("first")));
- list1.Append(new Bar(_T("second")));
-
- printf("After 1st list creation: %u objects in the list, %u objects total.\n",
- list1.GetCount(), Bar::GetNumber());
-
- wxListBars list2;
- list2 = list1;
-
- printf("After 2nd list creation: %u and %u objects in the lists, %u objects total.\n",
- list1.GetCount(), list2.GetCount(), Bar::GetNumber());
-
- list1.DeleteContents(TRUE);
- }
-
- printf("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 char *GetLangName(int lang)
-{
- static const char *languageNames[] =
- {
- "DEFAULT",
- "UNKNOWN",
- "ABKHAZIAN",
- "AFAR",
- "AFRIKAANS",
- "ALBANIAN",
- "AMHARIC",
- "ARABIC",
- "ARABIC_ALGERIA",
- "ARABIC_BAHRAIN",
- "ARABIC_EGYPT",
- "ARABIC_IRAQ",
- "ARABIC_JORDAN",
- "ARABIC_KUWAIT",
- "ARABIC_LEBANON",
- "ARABIC_LIBYA",
- "ARABIC_MOROCCO",
- "ARABIC_OMAN",
- "ARABIC_QATAR",
- "ARABIC_SAUDI_ARABIA",
- "ARABIC_SUDAN",
- "ARABIC_SYRIA",
- "ARABIC_TUNISIA",
- "ARABIC_UAE",
- "ARABIC_YEMEN",
- "ARMENIAN",
- "ASSAMESE",
- "AYMARA",
- "AZERI",
- "AZERI_CYRILLIC",
- "AZERI_LATIN",
- "BASHKIR",
- "BASQUE",
- "BELARUSIAN",
- "BENGALI",
- "BHUTANI",
- "BIHARI",
- "BISLAMA",
- "BRETON",
- "BULGARIAN",
- "BURMESE",
- "CAMBODIAN",
- "CATALAN",
- "CHINESE",
- "CHINESE_SIMPLIFIED",
- "CHINESE_TRADITIONAL",
- "CHINESE_HONGKONG",
- "CHINESE_MACAU",
- "CHINESE_SINGAPORE",
- "CHINESE_TAIWAN",
- "CORSICAN",
- "CROATIAN",
- "CZECH",
- "DANISH",
- "DUTCH",
- "DUTCH_BELGIAN",
- "ENGLISH",
- "ENGLISH_UK",
- "ENGLISH_US",
- "ENGLISH_AUSTRALIA",
- "ENGLISH_BELIZE",
- "ENGLISH_BOTSWANA",
- "ENGLISH_CANADA",
- "ENGLISH_CARIBBEAN",
- "ENGLISH_DENMARK",
- "ENGLISH_EIRE",
- "ENGLISH_JAMAICA",
- "ENGLISH_NEW_ZEALAND",
- "ENGLISH_PHILIPPINES",
- "ENGLISH_SOUTH_AFRICA",
- "ENGLISH_TRINIDAD",
- "ENGLISH_ZIMBABWE",
- "ESPERANTO",
- "ESTONIAN",
- "FAEROESE",
- "FARSI",
- "FIJI",
- "FINNISH",
- "FRENCH",
- "FRENCH_BELGIAN",
- "FRENCH_CANADIAN",
- "FRENCH_LUXEMBOURG",
- "FRENCH_MONACO",
- "FRENCH_SWISS",
- "FRISIAN",
- "GALICIAN",
- "GEORGIAN",
- "GERMAN",
- "GERMAN_AUSTRIAN",
- "GERMAN_BELGIUM",
- "GERMAN_LIECHTENSTEIN",
- "GERMAN_LUXEMBOURG",
- "GERMAN_SWISS",
- "GREEK",
- "GREENLANDIC",
- "GUARANI",
- "GUJARATI",
- "HAUSA",
- "HEBREW",
- "HINDI",
- "HUNGARIAN",
- "ICELANDIC",
- "INDONESIAN",
- "INTERLINGUA",
- "INTERLINGUE",
- "INUKTITUT",
- "INUPIAK",
- "IRISH",
- "ITALIAN",
- "ITALIAN_SWISS",
- "JAPANESE",
- "JAVANESE",
- "KANNADA",
- "KASHMIRI",
- "KASHMIRI_INDIA",
- "KAZAKH",
- "KERNEWEK",
- "KINYARWANDA",
- "KIRGHIZ",
- "KIRUNDI",
- "KONKANI",
- "KOREAN",
- "KURDISH",
- "LAOTHIAN",
- "LATIN",
- "LATVIAN",
- "LINGALA",
- "LITHUANIAN",
- "MACEDONIAN",
- "MALAGASY",
- "MALAY",
- "MALAYALAM",
- "MALAY_BRUNEI_DARUSSALAM",
- "MALAY_MALAYSIA",
- "MALTESE",
- "MANIPURI",
- "MAORI",
- "MARATHI",
- "MOLDAVIAN",
- "MONGOLIAN",
- "NAURU",
- "NEPALI",
- "NEPALI_INDIA",
- "NORWEGIAN_BOKMAL",
- "NORWEGIAN_NYNORSK",
- "OCCITAN",
- "ORIYA",
- "OROMO",
- "PASHTO",
- "POLISH",
- "PORTUGUESE",
- "PORTUGUESE_BRAZILIAN",
- "PUNJABI",
- "QUECHUA",
- "RHAETO_ROMANCE",
- "ROMANIAN",
- "RUSSIAN",
- "RUSSIAN_UKRAINE",
- "SAMOAN",
- "SANGHO",
- "SANSKRIT",
- "SCOTS_GAELIC",
- "SERBIAN",
- "SERBIAN_CYRILLIC",
- "SERBIAN_LATIN",
- "SERBO_CROATIAN",
- "SESOTHO",
- "SETSWANA",
- "SHONA",
- "SINDHI",
- "SINHALESE",
- "SISWATI",
- "SLOVAK",
- "SLOVENIAN",
- "SOMALI",
- "SPANISH",
- "SPANISH_ARGENTINA",
- "SPANISH_BOLIVIA",
- "SPANISH_CHILE",
- "SPANISH_COLOMBIA",
- "SPANISH_COSTA_RICA",
- "SPANISH_DOMINICAN_REPUBLIC",
- "SPANISH_ECUADOR",
- "SPANISH_EL_SALVADOR",
- "SPANISH_GUATEMALA",
- "SPANISH_HONDURAS",
- "SPANISH_MEXICAN",
- "SPANISH_MODERN",
- "SPANISH_NICARAGUA",
- "SPANISH_PANAMA",
- "SPANISH_PARAGUAY",
- "SPANISH_PERU",
- "SPANISH_PUERTO_RICO",
- "SPANISH_URUGUAY",
- "SPANISH_US",
- "SPANISH_VENEZUELA",
- "SUNDANESE",
- "SWAHILI",
- "SWEDISH",
- "SWEDISH_FINLAND",
- "TAGALOG",
- "TAJIK",
- "TAMIL",
- "TATAR",
- "TELUGU",
- "THAI",
- "TIBETAN",
- "TIGRINYA",
- "TONGA",
- "TSONGA",
- "TURKISH",
- "TURKMEN",
- "TWI",
- "UIGHUR",
- "UKRAINIAN",
- "URDU",
- "URDU_INDIA",
- "URDU_PAKISTAN",
- "UZBEK",
- "UZBEK_CYRILLIC",
- "UZBEK_LATIN",
- "VIETNAMESE",
- "VOLAPUK",
- "WELSH",
- "WOLOF",
- "XHOSA",
- "YIDDISH",
- "YORUBA",
- "ZHUANG",
- "ZULU",
- };
-
- if ( (size_t)lang < WXSIZEOF(languageNames) )
- return languageNames[lang];
- else
- return "INVALID";
-}
-
-static void TestDefaultLang()
-{
- puts("*** 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 char *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();
- printf("Locale for '%s' is %s.\n",
- langStr ? langStr : "system default", GetLangName(lang));
- }
-}
-
-#endif // TEST_LOCALE
-
-// ----------------------------------------------------------------------------
-// MIME types
-// ----------------------------------------------------------------------------
-
-#ifdef TEST_MIME