+ wxPuts(wxEmptyString);
+}
+
+static void TestMimeAssociate()
+{
+ wxPuts(wxT("*** Testing creation of filetype association ***\n"));
+
+ wxFileTypeInfo ftInfo(
+ wxT("application/x-xyz"),
+ wxT("xyzview '%s'"), // open cmd
+ wxT(""), // print cmd
+ wxT("XYZ File"), // description
+ wxT(".xyz"), // extensions
+ wxNullPtr // end of extensions
+ );
+ ftInfo.SetShortDesc(wxT("XYZFile")); // used under Win32 only
+
+ wxFileType *ft = wxTheMimeTypesManager->Associate(ftInfo);
+ if ( !ft )
+ {
+ wxPuts(wxT("ERROR: failed to create association!"));
+ }
+ else
+ {
+ // TODO: read it back
+ delete ft;
+ }
+
+ wxPuts(wxEmptyString);
+}
+
+#endif // 0
+
+#endif // TEST_MIME
+
+// ----------------------------------------------------------------------------
+// module dependencies feature
+// ----------------------------------------------------------------------------
+
+#ifdef TEST_MODULE
+
+#include "wx/module.h"
+
+class wxTestModule : public wxModule
+{
+protected:
+ virtual bool OnInit() { wxPrintf(wxT("Load module: %s\n"), GetClassInfo()->GetClassName()); return true; }
+ virtual void OnExit() { wxPrintf(wxT("Unload module: %s\n"), GetClassInfo()->GetClassName()); }
+};
+
+class wxTestModuleA : public wxTestModule
+{
+public:
+ wxTestModuleA();
+private:
+ DECLARE_DYNAMIC_CLASS(wxTestModuleA)
+};
+
+class wxTestModuleB : public wxTestModule
+{
+public:
+ wxTestModuleB();
+private:
+ DECLARE_DYNAMIC_CLASS(wxTestModuleB)
+};
+
+class wxTestModuleC : public wxTestModule
+{
+public:
+ wxTestModuleC();
+private:
+ DECLARE_DYNAMIC_CLASS(wxTestModuleC)
+};
+
+class wxTestModuleD : public wxTestModule
+{
+public:
+ wxTestModuleD();
+private:
+ DECLARE_DYNAMIC_CLASS(wxTestModuleD)
+};
+
+IMPLEMENT_DYNAMIC_CLASS(wxTestModuleC, wxModule)
+wxTestModuleC::wxTestModuleC()
+{
+ AddDependency(CLASSINFO(wxTestModuleD));
+}
+
+IMPLEMENT_DYNAMIC_CLASS(wxTestModuleA, wxModule)
+wxTestModuleA::wxTestModuleA()
+{
+ AddDependency(CLASSINFO(wxTestModuleB));
+ AddDependency(CLASSINFO(wxTestModuleD));
+}
+
+IMPLEMENT_DYNAMIC_CLASS(wxTestModuleD, wxModule)
+wxTestModuleD::wxTestModuleD()
+{
+}
+
+IMPLEMENT_DYNAMIC_CLASS(wxTestModuleB, wxModule)
+wxTestModuleB::wxTestModuleB()
+{
+ AddDependency(CLASSINFO(wxTestModuleD));
+ AddDependency(CLASSINFO(wxTestModuleC));
+}
+
+#endif // TEST_MODULE
+
+// ----------------------------------------------------------------------------
+// misc information functions
+// ----------------------------------------------------------------------------
+
+#ifdef TEST_INFO_FUNCTIONS
+
+#include "wx/utils.h"
+
+#if TEST_INTERACTIVE
+static void TestDiskInfo()
+{
+ wxPuts(wxT("*** Testing wxGetDiskSpace() ***"));
+
+ for ( ;; )
+ {
+ wxChar pathname[128];
+ wxPrintf(wxT("\nEnter a directory name: "));
+ if ( !wxFgets(pathname, WXSIZEOF(pathname), stdin) )
+ break;
+
+ // kill the last '\n'
+ pathname[wxStrlen(pathname) - 1] = 0;
+
+ wxLongLong total, free;
+ if ( !wxGetDiskSpace(pathname, &total, &free) )
+ {
+ wxPuts(wxT("ERROR: wxGetDiskSpace failed."));
+ }
+ else
+ {
+ wxPrintf(wxT("%sKb total, %sKb free on '%s'.\n"),
+ (total / 1024).ToString().c_str(),
+ (free / 1024).ToString().c_str(),
+ pathname);
+ }
+ }
+}
+#endif // TEST_INTERACTIVE
+
+static void TestOsInfo()
+{
+ wxPuts(wxT("*** Testing OS info functions ***\n"));
+
+ int major, minor;
+ wxGetOsVersion(&major, &minor);
+ wxPrintf(wxT("Running under: %s, version %d.%d\n"),
+ wxGetOsDescription().c_str(), major, minor);
+
+ wxPrintf(wxT("%ld free bytes of memory left.\n"), wxGetFreeMemory().ToLong());
+
+ wxPrintf(wxT("Host name is %s (%s).\n"),
+ wxGetHostName().c_str(), wxGetFullHostName().c_str());
+
+ wxPuts(wxEmptyString);
+}
+
+static void TestPlatformInfo()
+{
+ wxPuts(wxT("*** Testing wxPlatformInfo functions ***\n"));
+
+ // get this platform
+ wxPlatformInfo plat;
+
+ wxPrintf(wxT("Operating system family name is: %s\n"), plat.GetOperatingSystemFamilyName().c_str());
+ wxPrintf(wxT("Operating system name is: %s\n"), plat.GetOperatingSystemIdName().c_str());
+ wxPrintf(wxT("Port ID name is: %s\n"), plat.GetPortIdName().c_str());
+ wxPrintf(wxT("Port ID short name is: %s\n"), plat.GetPortIdShortName().c_str());
+ wxPrintf(wxT("Architecture is: %s\n"), plat.GetArchName().c_str());
+ wxPrintf(wxT("Endianness is: %s\n"), plat.GetEndiannessName().c_str());
+
+ wxPuts(wxEmptyString);
+}
+
+static void TestUserInfo()
+{
+ wxPuts(wxT("*** Testing user info functions ***\n"));
+
+ wxPrintf(wxT("User id is:\t%s\n"), wxGetUserId().c_str());
+ wxPrintf(wxT("User name is:\t%s\n"), wxGetUserName().c_str());
+ wxPrintf(wxT("Home dir is:\t%s\n"), wxGetHomeDir().c_str());
+ wxPrintf(wxT("Email address:\t%s\n"), wxGetEmailAddress().c_str());
+
+ wxPuts(wxEmptyString);
+}
+
+#endif // TEST_INFO_FUNCTIONS
+
+// ----------------------------------------------------------------------------
+// path list
+// ----------------------------------------------------------------------------
+
+#ifdef TEST_PATHLIST
+
+#ifdef __UNIX__
+ #define CMD_IN_PATH wxT("ls")
+#else
+ #define CMD_IN_PATH wxT("command.com")
+#endif
+
+static void TestPathList()
+{
+ wxPuts(wxT("*** Testing wxPathList ***\n"));
+
+ wxPathList pathlist;
+ pathlist.AddEnvList(wxT("PATH"));
+ wxString path = pathlist.FindValidPath(CMD_IN_PATH);
+ if ( path.empty() )
+ {
+ wxPrintf(wxT("ERROR: command not found in the path.\n"));
+ }
+ else
+ {
+ wxPrintf(wxT("Command found in the path as '%s'.\n"), path.c_str());
+ }
+}
+
+#endif // TEST_PATHLIST
+
+// ----------------------------------------------------------------------------
+// regular expressions
+// ----------------------------------------------------------------------------
+
+#if defined TEST_REGEX && TEST_INTERACTIVE
+
+#include "wx/regex.h"
+
+static void TestRegExInteractive()
+{
+ wxPuts(wxT("*** Testing RE interactively ***"));
+
+ for ( ;; )
+ {
+ wxChar pattern[128];
+ wxPrintf(wxT("\nEnter a pattern: "));
+ if ( !wxFgets(pattern, WXSIZEOF(pattern), stdin) )
+ break;
+
+ // kill the last '\n'
+ pattern[wxStrlen(pattern) - 1] = 0;
+
+ wxRegEx re;
+ if ( !re.Compile(pattern) )
+ {
+ continue;
+ }
+
+ wxChar text[128];
+ for ( ;; )
+ {
+ wxPrintf(wxT("Enter text to match: "));
+ if ( !wxFgets(text, WXSIZEOF(text), stdin) )
+ break;
+
+ // kill the last '\n'
+ text[wxStrlen(text) - 1] = 0;
+
+ if ( !re.Matches(text) )
+ {
+ wxPrintf(wxT("No match.\n"));
+ }
+ else
+ {
+ wxPrintf(wxT("Pattern matches at '%s'\n"), re.GetMatch(text).c_str());
+
+ size_t start, len;
+ for ( size_t n = 1; ; n++ )
+ {
+ if ( !re.GetMatch(&start, &len, n) )
+ {
+ break;
+ }
+
+ wxPrintf(wxT("Subexpr %u matched '%s'\n"),
+ n, wxString(text + start, len).c_str());
+ }
+ }
+ }
+ }
+}
+
+#endif // TEST_REGEX
+
+// ----------------------------------------------------------------------------
+// printf() tests
+// ----------------------------------------------------------------------------
+
+/*
+ NB: this stuff was taken from the glibc test suite and modified to build
+ in wxWidgets: if I read the copyright below properly, this shouldn't
+ be a problem
+ */
+
+#ifdef TEST_PRINTF
+
+#ifdef wxTEST_PRINTF
+ // use our functions from wxchar.cpp
+ #undef wxPrintf
+ #undef wxSprintf
+
+ // NB: do _not_ use WX_ATTRIBUTE_PRINTF here, we have some invalid formats
+ // in the tests below
+ int wxPrintf( const wxChar *format, ... );
+ int wxSprintf( wxChar *str, const wxChar *format, ... );
+#endif
+
+#include "wx/longlong.h"
+
+#include <float.h>
+
+static void rfg1 (void);
+static void rfg2 (void);
+
+
+static void
+fmtchk (const wxChar *fmt)
+{
+ (void) wxPrintf(wxT("%s:\t`"), fmt);
+ (void) wxPrintf(fmt, 0x12);
+ (void) wxPrintf(wxT("'\n"));
+}
+
+static void
+fmtst1chk (const wxChar *fmt)
+{
+ (void) wxPrintf(wxT("%s:\t`"), fmt);
+ (void) wxPrintf(fmt, 4, 0x12);
+ (void) wxPrintf(wxT("'\n"));
+}
+
+static void
+fmtst2chk (const wxChar *fmt)
+{
+ (void) wxPrintf(wxT("%s:\t`"), fmt);
+ (void) wxPrintf(fmt, 4, 4, 0x12);
+ (void) wxPrintf(wxT("'\n"));
+}
+
+/* This page is covered by the following copyright: */
+
+/* (C) Copyright C E Chew
+ *
+ * Feel free to copy, use and distribute this software provided:
+ *
+ * 1. you do not pretend that you wrote it
+ * 2. you leave this copyright notice intact.
+ */
+
+/*
+ * Extracted from exercise.c for glibc-1.05 bug report by Bruce Evans.
+ */
+
+#define DEC -123
+#define INT 255
+#define UNS (~0)
+
+/* Formatted Output Test
+ *
+ * This exercises the output formatting code.
+ */
+
+wxChar *PointerNull = NULL;
+
+static void
+fp_test (void)
+{
+ int i, j, k, l;
+ wxChar buf[7];
+ wxChar *prefix = buf;
+ wxChar tp[20];
+
+ wxPuts(wxT("\nFormatted output test"));
+ wxPrintf(wxT("prefix 6d 6o 6x 6X 6u\n"));
+ wxStrcpy(prefix, wxT("%"));
+ for (i = 0; i < 2; i++) {
+ for (j = 0; j < 2; j++) {
+ for (k = 0; k < 2; k++) {
+ for (l = 0; l < 2; l++) {
+ wxStrcpy(prefix, wxT("%"));
+ if (i == 0) wxStrcat(prefix, wxT("-"));
+ if (j == 0) wxStrcat(prefix, wxT("+"));
+ if (k == 0) wxStrcat(prefix, wxT("#"));
+ if (l == 0) wxStrcat(prefix, wxT("0"));
+ wxPrintf(wxT("%5s |"), prefix);
+ wxStrcpy(tp, prefix);
+ wxStrcat(tp, wxT("6d |"));
+ wxPrintf(tp, DEC);
+ wxStrcpy(tp, prefix);
+ wxStrcat(tp, wxT("6o |"));
+ wxPrintf(tp, INT);
+ wxStrcpy(tp, prefix);
+ wxStrcat(tp, wxT("6x |"));
+ wxPrintf(tp, INT);
+ wxStrcpy(tp, prefix);
+ wxStrcat(tp, wxT("6X |"));
+ wxPrintf(tp, INT);
+ wxStrcpy(tp, prefix);
+ wxStrcat(tp, wxT("6u |"));
+ wxPrintf(tp, UNS);
+ wxPrintf(wxT("\n"));
+ }
+ }
+ }
+ }
+ wxPrintf(wxT("%10s\n"), PointerNull);
+ wxPrintf(wxT("%-10s\n"), PointerNull);
+}
+
+static void TestPrintf()
+{
+ static wxChar shortstr[] = wxT("Hi, Z.");
+ static wxChar longstr[] = wxT("Good morning, Doctor Chandra. This is Hal. \
+I am ready for my first lesson today.");
+ int result = 0;
+ wxString test_format;
+
+ fmtchk(wxT("%.4x"));
+ fmtchk(wxT("%04x"));
+ fmtchk(wxT("%4.4x"));
+ fmtchk(wxT("%04.4x"));
+ fmtchk(wxT("%4.3x"));
+ fmtchk(wxT("%04.3x"));
+
+ fmtst1chk(wxT("%.*x"));
+ fmtst1chk(wxT("%0*x"));
+ fmtst2chk(wxT("%*.*x"));
+ fmtst2chk(wxT("%0*.*x"));
+
+ wxString bad_format = wxT("bad format:\t\"%b\"\n");
+ wxPrintf(bad_format.c_str());
+ wxPrintf(wxT("nil pointer (padded):\t\"%10p\"\n"), (void *) NULL);
+
+ wxPrintf(wxT("decimal negative:\t\"%d\"\n"), -2345);
+ wxPrintf(wxT("octal negative:\t\"%o\"\n"), -2345);
+ wxPrintf(wxT("hex negative:\t\"%x\"\n"), -2345);
+ wxPrintf(wxT("long decimal number:\t\"%ld\"\n"), -123456L);
+ wxPrintf(wxT("long octal negative:\t\"%lo\"\n"), -2345L);
+ wxPrintf(wxT("long unsigned decimal number:\t\"%lu\"\n"), -123456L);
+ wxPrintf(wxT("zero-padded LDN:\t\"%010ld\"\n"), -123456L);
+ test_format = wxT("left-adjusted ZLDN:\t\"%-010ld\"\n");
+ wxPrintf(test_format.c_str(), -123456);
+ wxPrintf(wxT("space-padded LDN:\t\"%10ld\"\n"), -123456L);
+ wxPrintf(wxT("left-adjusted SLDN:\t\"%-10ld\"\n"), -123456L);
+
+ test_format = wxT("zero-padded string:\t\"%010s\"\n");
+ wxPrintf(test_format.c_str(), shortstr);
+ test_format = wxT("left-adjusted Z string:\t\"%-010s\"\n");
+ wxPrintf(test_format.c_str(), shortstr);
+ wxPrintf(wxT("space-padded string:\t\"%10s\"\n"), shortstr);
+ wxPrintf(wxT("left-adjusted S string:\t\"%-10s\"\n"), shortstr);
+ wxPrintf(wxT("null string:\t\"%s\"\n"), PointerNull);
+ wxPrintf(wxT("limited string:\t\"%.22s\"\n"), longstr);
+
+ wxPrintf(wxT("e-style >= 1:\t\"%e\"\n"), 12.34);
+ wxPrintf(wxT("e-style >= .1:\t\"%e\"\n"), 0.1234);
+ wxPrintf(wxT("e-style < .1:\t\"%e\"\n"), 0.001234);
+ wxPrintf(wxT("e-style big:\t\"%.60e\"\n"), 1e20);
+ wxPrintf(wxT("e-style == .1:\t\"%e\"\n"), 0.1);
+ wxPrintf(wxT("f-style >= 1:\t\"%f\"\n"), 12.34);
+ wxPrintf(wxT("f-style >= .1:\t\"%f\"\n"), 0.1234);
+ wxPrintf(wxT("f-style < .1:\t\"%f\"\n"), 0.001234);
+ wxPrintf(wxT("g-style >= 1:\t\"%g\"\n"), 12.34);
+ wxPrintf(wxT("g-style >= .1:\t\"%g\"\n"), 0.1234);
+ wxPrintf(wxT("g-style < .1:\t\"%g\"\n"), 0.001234);
+ wxPrintf(wxT("g-style big:\t\"%.60g\"\n"), 1e20);
+
+ wxPrintf (wxT(" %6.5f\n"), .099999999860301614);
+ wxPrintf (wxT(" %6.5f\n"), .1);
+ wxPrintf (wxT("x%5.4fx\n"), .5);
+
+ wxPrintf (wxT("%#03x\n"), 1);
+
+ //wxPrintf (wxT("something really insane: %.10000f\n"), 1.0);
+
+ {
+ double d = FLT_MIN;
+ int niter = 17;
+
+ while (niter-- != 0)
+ wxPrintf (wxT("%.17e\n"), d / 2);
+ fflush (stdout);
+ }
+
+#ifndef __WATCOMC__
+ // Open Watcom cause compiler error here
+ // Error! E173: col(24) floating-point constant too small to represent
+ wxPrintf (wxT("%15.5e\n"), 4.9406564584124654e-324);
+#endif
+
+#define FORMAT wxT("|%12.4f|%12.4e|%12.4g|\n")
+ wxPrintf (FORMAT, 0.0, 0.0, 0.0);
+ wxPrintf (FORMAT, 1.0, 1.0, 1.0);
+ wxPrintf (FORMAT, -1.0, -1.0, -1.0);
+ wxPrintf (FORMAT, 100.0, 100.0, 100.0);
+ wxPrintf (FORMAT, 1000.0, 1000.0, 1000.0);
+ wxPrintf (FORMAT, 10000.0, 10000.0, 10000.0);
+ wxPrintf (FORMAT, 12345.0, 12345.0, 12345.0);
+ wxPrintf (FORMAT, 100000.0, 100000.0, 100000.0);
+ wxPrintf (FORMAT, 123456.0, 123456.0, 123456.0);
+#undef FORMAT
+
+ {
+ wxChar buf[20];
+ int rc = wxSnprintf (buf, WXSIZEOF(buf), wxT("%30s"), wxT("foo"));
+
+ wxPrintf(wxT("snprintf (\"%%30s\", \"foo\") == %d, \"%.*s\"\n"),
+ rc, WXSIZEOF(buf), buf);
+#if 0
+ wxChar buf2[512];
+ wxPrintf ("snprintf (\"%%.999999u\", 10)\n",
+ wxSnprintf(buf2, WXSIZEOFbuf2), "%.999999u", 10));
+#endif
+ }
+
+ fp_test ();
+
+ wxPrintf (wxT("%e should be 1.234568e+06\n"), 1234567.8);
+ wxPrintf (wxT("%f should be 1234567.800000\n"), 1234567.8);
+ wxPrintf (wxT("%g should be 1.23457e+06\n"), 1234567.8);
+ wxPrintf (wxT("%g should be 123.456\n"), 123.456);
+ wxPrintf (wxT("%g should be 1e+06\n"), 1000000.0);
+ wxPrintf (wxT("%g should be 10\n"), 10.0);
+ wxPrintf (wxT("%g should be 0.02\n"), 0.02);
+
+ {
+ double x=1.0;
+ wxPrintf(wxT("%.17f\n"),(1.0/x/10.0+1.0)*x-x);
+ }
+
+ {
+ wxChar buf[200];
+
+ wxSprintf(buf,wxT("%*s%*s%*s"),-1,wxT("one"),-20,wxT("two"),-30,wxT("three"));
+
+ result |= wxStrcmp (buf,
+ wxT("onetwo three "));
+
+ wxPuts (result != 0 ? wxT("Test failed!") : wxT("Test ok."));
+ }
+
+#ifdef wxLongLong_t
+ {
+ wxChar buf[200];
+
+ wxSprintf(buf, wxT("%07") wxLongLongFmtSpec wxT("o"), wxLL(040000000000));
+ #if 0
+ // for some reason below line fails under Borland
+ wxPrintf (wxT("sprintf (buf, \"%%07Lo\", 040000000000ll) = %s"), buf);
+ #endif
+
+ if (wxStrcmp (buf, wxT("40000000000")) != 0)
+ {
+ result = 1;
+ wxPuts (wxT("\tFAILED"));
+ }
+ wxUnusedVar(result);
+ wxPuts (wxEmptyString);
+ }
+#endif // wxLongLong_t
+
+ wxPrintf (wxT("printf (\"%%hhu\", %u) = %hhu\n"), UCHAR_MAX + 2, UCHAR_MAX + 2);
+ wxPrintf (wxT("printf (\"%%hu\", %u) = %hu\n"), USHRT_MAX + 2, USHRT_MAX + 2);
+
+ wxPuts (wxT("--- Should be no further output. ---"));
+ rfg1 ();
+ rfg2 ();
+
+#if 0
+ {
+ wxChar bytes[7];
+ wxChar buf[20];
+
+ memset (bytes, '\xff', sizeof bytes);
+ wxSprintf (buf, wxT("foo%hhn\n"), &bytes[3]);
+ if (bytes[0] != '\xff' || bytes[1] != '\xff' || bytes[2] != '\xff'
+ || bytes[4] != '\xff' || bytes[5] != '\xff' || bytes[6] != '\xff')
+ {
+ wxPuts (wxT("%hhn overwrite more bytes"));
+ result = 1;
+ }
+ if (bytes[3] != 3)
+ {
+ wxPuts (wxT("%hhn wrote incorrect value"));
+ result = 1;
+ }
+ }
+#endif
+}
+
+static void
+rfg1 (void)
+{
+ wxChar buf[100];
+
+ wxSprintf (buf, wxT("%5.s"), wxT("xyz"));
+ if (wxStrcmp (buf, wxT(" ")) != 0)
+ wxPrintf (wxT("got: '%s', expected: '%s'\n"), buf, wxT(" "));
+ wxSprintf (buf, wxT("%5.f"), 33.3);
+ if (wxStrcmp (buf, wxT(" 33")) != 0)
+ wxPrintf (wxT("got: '%s', expected: '%s'\n"), buf, wxT(" 33"));
+ wxSprintf (buf, wxT("%8.e"), 33.3e7);
+ if (wxStrcmp (buf, wxT(" 3e+08")) != 0)
+ wxPrintf (wxT("got: '%s', expected: '%s'\n"), buf, wxT(" 3e+08"));
+ wxSprintf (buf, wxT("%8.E"), 33.3e7);
+ if (wxStrcmp (buf, wxT(" 3E+08")) != 0)
+ wxPrintf (wxT("got: '%s', expected: '%s'\n"), buf, wxT(" 3E+08"));
+ wxSprintf (buf, wxT("%.g"), 33.3);
+ if (wxStrcmp (buf, wxT("3e+01")) != 0)
+ wxPrintf (wxT("got: '%s', expected: '%s'\n"), buf, wxT("3e+01"));
+ wxSprintf (buf, wxT("%.G"), 33.3);
+ if (wxStrcmp (buf, wxT("3E+01")) != 0)
+ wxPrintf (wxT("got: '%s', expected: '%s'\n"), buf, wxT("3E+01"));
+}
+
+static void
+rfg2 (void)
+{
+ int prec;
+ wxChar buf[100];
+ wxString test_format;
+
+ prec = 0;
+ wxSprintf (buf, wxT("%.*g"), prec, 3.3);
+ if (wxStrcmp (buf, wxT("3")) != 0)
+ wxPrintf (wxT("got: '%s', expected: '%s'\n"), buf, wxT("3"));
+ prec = 0;
+ wxSprintf (buf, wxT("%.*G"), prec, 3.3);
+ if (wxStrcmp (buf, wxT("3")) != 0)
+ wxPrintf (wxT("got: '%s', expected: '%s'\n"), buf, wxT("3"));
+ prec = 0;
+ wxSprintf (buf, wxT("%7.*G"), prec, 3.33);
+ if (wxStrcmp (buf, wxT(" 3")) != 0)
+ wxPrintf (wxT("got: '%s', expected: '%s'\n"), buf, wxT(" 3"));
+ prec = 3;
+ test_format = wxT("%04.*o");
+ wxSprintf (buf, test_format.c_str(), prec, 33);
+ if (wxStrcmp (buf, wxT(" 041")) != 0)
+ wxPrintf (wxT("got: '%s', expected: '%s'\n"), buf, wxT(" 041"));
+ prec = 7;
+ test_format = wxT("%09.*u");
+ wxSprintf (buf, test_format.c_str(), prec, 33);
+ if (wxStrcmp (buf, wxT(" 0000033")) != 0)
+ wxPrintf (wxT("got: '%s', expected: '%s'\n"), buf, wxT(" 0000033"));
+ prec = 3;
+ test_format = wxT("%04.*x");
+ wxSprintf (buf, test_format.c_str(), prec, 33);
+ if (wxStrcmp (buf, wxT(" 021")) != 0)
+ wxPrintf (wxT("got: '%s', expected: '%s'\n"), buf, wxT(" 021"));
+ prec = 3;
+ test_format = wxT("%04.*X");
+ wxSprintf (buf, test_format.c_str(), prec, 33);
+ if (wxStrcmp (buf, wxT(" 021")) != 0)
+ wxPrintf (wxT("got: '%s', expected: '%s'\n"), buf, wxT(" 021"));
+}
+
+#endif // TEST_PRINTF
+
+// ----------------------------------------------------------------------------
+// registry and related stuff
+// ----------------------------------------------------------------------------
+
+// this is for MSW only
+#ifndef __WXMSW__
+ #undef TEST_REGCONF
+ #undef TEST_REGISTRY
+#endif
+
+#ifdef TEST_REGCONF
+
+#include "wx/confbase.h"
+#include "wx/msw/regconf.h"
+
+#if 0
+static void TestRegConfWrite()
+{
+ wxConfig *config = new wxConfig(wxT("myapp"));
+ config->SetPath(wxT("/group1"));
+ config->Write(wxT("entry1"), wxT("foo"));
+ config->SetPath(wxT("/group2"));
+ config->Write(wxT("entry1"), wxT("bar"));
+}
+#endif
+
+static void TestRegConfRead()
+{
+ wxRegConfig *config = new wxRegConfig(wxT("myapp"));
+
+ wxString str;
+ long dummy;
+ config->SetPath(wxT("/"));
+ wxPuts(wxT("Enumerating / subgroups:"));
+ bool bCont = config->GetFirstGroup(str, dummy);
+ while(bCont)
+ {
+ wxPuts(str);
+ bCont = config->GetNextGroup(str, dummy);
+ }
+}
+
+#endif // TEST_REGCONF
+
+#ifdef TEST_REGISTRY
+
+#include "wx/msw/registry.h"
+
+// I chose this one because I liked its name, but it probably only exists under
+// NT
+static const wxChar *TESTKEY =
+ wxT("HKEY_LOCAL_MACHINE\\SYSTEM\\ControlSet001\\Control\\CrashControl");
+
+static void TestRegistryRead()
+{
+ wxPuts(wxT("*** testing registry reading ***"));
+
+ wxRegKey key(TESTKEY);
+ wxPrintf(wxT("The test key name is '%s'.\n"), key.GetName().c_str());
+ if ( !key.Open() )
+ {
+ wxPuts(wxT("ERROR: test key can't be opened, aborting test."));