wxCmdLineParser tests
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@5247 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -30,18 +30,59 @@
|
|||||||
// what to test?
|
// what to test?
|
||||||
|
|
||||||
//#define TEST_ARRAYS
|
//#define TEST_ARRAYS
|
||||||
|
#define TEST_CMDLINE
|
||||||
//#define TEST_DIR
|
//#define TEST_DIR
|
||||||
//#define TEST_LOG
|
//#define TEST_LOG
|
||||||
//#define TEST_LONGLONG
|
//#define TEST_LONGLONG
|
||||||
//#define TEST_MIME
|
//#define TEST_MIME
|
||||||
//#define TEST_STRINGS
|
//#define TEST_STRINGS
|
||||||
#define TEST_THREADS
|
//#define TEST_THREADS
|
||||||
//#define TEST_TIME
|
//#define TEST_TIME
|
||||||
|
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
// implementation
|
// implementation
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
|
|
||||||
|
#ifdef TEST_CMDLINE
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// wxCmdLineParser
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#include <wx/cmdline.h>
|
||||||
|
#include <wx/datetime.h>
|
||||||
|
|
||||||
|
static void ShowCmdLine(const wxCmdLineParser& parser)
|
||||||
|
{
|
||||||
|
wxString s = "Input files: ";
|
||||||
|
|
||||||
|
size_t count = parser.GetParamCount();
|
||||||
|
for ( size_t param = 0; param < count; param++ )
|
||||||
|
{
|
||||||
|
s << parser.GetParam(param) << ' ';
|
||||||
|
}
|
||||||
|
|
||||||
|
s << '\n'
|
||||||
|
<< "Verbose:\t" << (parser.Found("v") ? "yes" : "no") << '\n'
|
||||||
|
<< "Quiet:\t" << (parser.Found("q") ? "yes" : "no") << '\n';
|
||||||
|
|
||||||
|
wxString strVal;
|
||||||
|
long lVal;
|
||||||
|
wxDateTime dt;
|
||||||
|
if ( parser.Found("o", &strVal) )
|
||||||
|
s << "Output file:\t" << strVal << '\n';
|
||||||
|
if ( parser.Found("i", &strVal) )
|
||||||
|
s << "Input dir:\t" << strVal << '\n';
|
||||||
|
if ( parser.Found("s", &lVal) )
|
||||||
|
s << "Size:\t" << lVal << '\n';
|
||||||
|
if ( parser.Found("d", &dt) )
|
||||||
|
s << "Date:\t" << dt.FormatISODate() << '\n';
|
||||||
|
|
||||||
|
wxLogMessage(s);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // TEST_CMDLINE
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// wxDir
|
// wxDir
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
@@ -1538,6 +1579,41 @@ int main(int argc, char **argv)
|
|||||||
fprintf(stderr, "Failed to initialize the wxWindows library, aborting.");
|
fprintf(stderr, "Failed to initialize the wxWindows library, aborting.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef TEST_CMDLINE
|
||||||
|
static const wxCmdLineEntryDesc cmdLineDesc[] =
|
||||||
|
{
|
||||||
|
{ wxCMD_LINE_SWITCH, "v", "verbose", "be verbose" },
|
||||||
|
{ wxCMD_LINE_SWITCH, "q", "quiet", "be quiet" },
|
||||||
|
|
||||||
|
{ wxCMD_LINE_OPTION, "o", "output", "output file" },
|
||||||
|
{ wxCMD_LINE_OPTION, "i", "input", "input dir" },
|
||||||
|
{ wxCMD_LINE_OPTION, "s", "size", "output block size", wxCMD_LINE_VAL_NUMBER },
|
||||||
|
{ wxCMD_LINE_OPTION, "d", "date", "output file date", wxCMD_LINE_VAL_NUMBER },
|
||||||
|
|
||||||
|
{ wxCMD_LINE_PARAM, NULL, NULL, "input file",
|
||||||
|
wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_MULTIPLE },
|
||||||
|
|
||||||
|
{ wxCMD_LINE_NONE }
|
||||||
|
};
|
||||||
|
|
||||||
|
wxCmdLineParser parser(cmdLineDesc, argc, argv);
|
||||||
|
|
||||||
|
switch ( parser.Parse() )
|
||||||
|
{
|
||||||
|
case -1:
|
||||||
|
wxLogMessage("Help was given, terminating.");
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 0:
|
||||||
|
ShowCmdLine(parser);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
wxLogMessage("Syntax error detected, aborting.");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
#endif // TEST_CMDLINE
|
||||||
|
|
||||||
#ifdef TEST_STRINGS
|
#ifdef TEST_STRINGS
|
||||||
if ( 0 )
|
if ( 0 )
|
||||||
{
|
{
|
||||||
|
@@ -522,7 +522,8 @@ LifeCanvas::LifeCanvas(wxWindow *parent, Life *life)
|
|||||||
{
|
{
|
||||||
m_life = life;
|
m_life = life;
|
||||||
m_cellsize = 8;
|
m_cellsize = 8;
|
||||||
m_bmp = NULL;
|
m_bmp = NULL;
|
||||||
|
|
||||||
Reset();
|
Reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -812,7 +813,7 @@ bool Life::HasChanged(int x, int y) const
|
|||||||
{
|
{
|
||||||
wxASSERT(x < m_width || y < m_height);
|
wxASSERT(x < m_width || y < m_height);
|
||||||
|
|
||||||
return (m_cells[y * m_width + x] & CELL_MARK);
|
return (m_cells[y * m_width + x] & CELL_MARK) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Life::SetCell(int x, int y, bool alive)
|
void Life::SetCell(int x, int y, bool alive)
|
||||||
|
Reference in New Issue
Block a user