3. Run the test program with no arguments to run the default set of tests
(which are all those registered with CPPUNIT_TEST_SUITE_REGISTRATION).
- Or to list the tests without running them:
+ Or to list the test suites without running them:
test -l
4. Tests that have been registered under a name using
example:
test MBConvTestCase
or to list the tests:
- test -l MBConvTestCase
+ test -L MBConvTestCase
IV. Notes
1. You can register your tests (or a subset of them) just under a name, and not
in the unnamed registry if you don't want them to be executed by default.
-2. If you are going to register your tests both in the unnamed registry and
- under a name, then use the name that the tests have in the 'test -l'
- listing (which is often the name of the TestCase class). Then the top
- level names in a 'test -l' listing can be a hint as to the name those
- tests have been registered under.
+2. If you are going to register your tests both in the unnamed registry
+ and under a name, then use the name that the tests have in the 'test -l'
+ listing.
+
+3. Tests which fail can be temporarily registered under "fixme" while the
+ problems they expose are fixed, instead of the unnamed registry. That
+ way they can easily be run, but they do not make regression testing with
+ the default suite more difficult. E.g.:
+
+ // register in the unnamed registry so that these tests are run by default
+ //CPPUNIT_TEST_SUITE_REGISTRATION(wxRegExTestCase);
+ CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(wxRegExTestCase, "fixme");
+
+ // also include in it's own registry so that these tests can be run alone
+ CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(wxRegExTestCase, "wxRegExTestCase");
+
+4. Tests which take a long time to execute can be registered under "advanced"
+ instead of the unnamed registry. The default suite should execute reasonably
+ quickly. To run the default and advanced tests together:
+ test "" advanced
=== EOF ===
// CPPUNIT_ASSERT(wxString::Format(_T("%hs"), "test") == _T("test"));
//
-#if defined(__GNUG__) && !defined(__APPLE__)
- #pragma implementation
- #pragma interface
-#endif
-
// For compilers that support precompilation, includes "wx/wx.h".
#include "wx/wxprec.h"
#endif
CPPUNIT_TEST_SUITE_END();
-private:
void format_d();
void format_hd();
void format_ld();
doTest(_T("d"), _T("d"));
#endif
CPPUNIT_ASSERT(wxString::Format(_T("%d"), 255) == _T("255"));
+ CPPUNIT_ASSERT(wxString::Format(_T("%05d"), 255) == _T("00255"));
+ CPPUNIT_ASSERT(wxString::Format(_T("% 5d"), 255) == _T(" 255"));
+ CPPUNIT_ASSERT(wxString::Format(_T("% 5d"), -255) == _T(" -255"));
+ CPPUNIT_ASSERT(wxString::Format(_T("%-5d"), -255) == _T("-255 "));
+ CPPUNIT_ASSERT(wxString::Format(_T("%+5d"), 255) == _T(" +255"));
+ CPPUNIT_ASSERT(wxString::Format(_T("%*d"), 5, 255) == _T(" 255"));
}
void FormatConverterTestCase::format_hd()
#ifdef CAN_TEST
doTest(_T("s"), _T("ls"));
#endif
- CPPUNIT_ASSERT(wxString::Format(_T("%s"), _T("test")) == _T("test"));
+ CPPUNIT_ASSERT(wxString::Format(_T("%s!"), _T("test")) == _T("test!"));
+ CPPUNIT_ASSERT(wxString::Format(_T("%6s!"), _T("test")) == _T(" test!"));
+ CPPUNIT_ASSERT(wxString::Format(_T("%-6s!"), _T("test")) == _T("test !"));
+ CPPUNIT_ASSERT(wxString::Format(_T("%.6s!"), _T("test")) == _T("test!"));
+ CPPUNIT_ASSERT(wxString::Format(_T("%6.4s!"), _T("testing")) == _T(" test!"));
}
void FormatConverterTestCase::format_hs()
#ifdef CAN_TEST
doTest(_T("hs"), _T("hs"));
#endif
- CPPUNIT_ASSERT(wxString::Format(_T("%hs"), "test") == _T("test"));
+ CPPUNIT_ASSERT(wxString::Format(wxString(_T("%hs!")), "test") == _T("test!"));
+ CPPUNIT_ASSERT(wxString::Format(wxString(_T("%6hs!")), "test") == _T(" test!"));
+ CPPUNIT_ASSERT(wxString::Format(wxString(_T("%-6hs!")), "test") == _T("test !"));
+ CPPUNIT_ASSERT(wxString::Format(wxString(_T("%.6hs!")), "test") == _T("test!"));
+ CPPUNIT_ASSERT(wxString::Format(wxString(_T("%6.4hs!")), "testing") == _T(" test!"));
}
void FormatConverterTestCase::format_ls()
#ifdef CAN_TEST
doTest(_T("ls"), _T("ls"));
#endif
- CPPUNIT_ASSERT(wxString::Format(_T("%ls"), L"test") == _T("test"));
+ CPPUNIT_ASSERT(wxString::Format(_T("%ls!"), L"test") == _T("test!"));
+ CPPUNIT_ASSERT(wxString::Format(_T("%6ls!"), L"test") == _T(" test!"));
+ CPPUNIT_ASSERT(wxString::Format(_T("%-6ls!"), L"test") == _T("test !"));
+ CPPUNIT_ASSERT(wxString::Format(_T("%.6ls!"), L"test") == _T("test!"));
+ CPPUNIT_ASSERT(wxString::Format(_T("%6.4ls!"), L"testing") == _T(" test!"));
}
void FormatConverterTestCase::format_c()
doTest(_T("c"), _T("lc"));
#endif
CPPUNIT_ASSERT(wxString::Format(_T("%c"), _T('x')) == _T("x"));
+ CPPUNIT_ASSERT(wxString::Format(_T("%2c"), _T('x')) == _T(" x"));
+ CPPUNIT_ASSERT(wxString::Format(_T("%-2c"), _T('x')) == _T("x "));
}
void FormatConverterTestCase::format_hc()
#ifdef CAN_TEST
doTest(_T("hc"), _T("hc"));
#endif
- CPPUNIT_ASSERT(wxString::Format(_T("%hc"), 'x') == _T("x"));
+ CPPUNIT_ASSERT(wxString::Format(wxString(_T("%hc")), 'x') == _T("x"));
+ CPPUNIT_ASSERT(wxString::Format(wxString(_T("%2hc")), 'x') == _T(" x"));
+ CPPUNIT_ASSERT(wxString::Format(wxString(_T("%-2hc")), 'x') == _T("x "));
}
void FormatConverterTestCase::format_lc()
doTest(_T("lc"), _T("lc"));
#endif
CPPUNIT_ASSERT(wxString::Format(_T("%lc"), L'x') == _T("x"));
+ CPPUNIT_ASSERT(wxString::Format(_T("%2lc"), L'x') == _T(" x"));
+ CPPUNIT_ASSERT(wxString::Format(_T("%-2lc"), L'x') == _T("x "));
}
#ifdef CAN_TEST
int OnRun();
private:
- void List(Test *test, int depth = 0) const;
+ void List(Test *test, const string& parent = "") const;
// command lines options/parameters
bool m_list;
IMPLEMENT_APP_CONSOLE(TestApp)
TestApp::TestApp()
- : m_list(false)
+ : m_list(false),
+ m_longlist(false)
{
}
// List the tests
//
-void TestApp::List(Test *test, int depth /*=0*/) const
+void TestApp::List(Test *test, const string& parent /*=""*/) const
{
TestSuite *suite = dynamic_cast<TestSuite*>(test);
-
- if (suite || m_longlist)
- cout << string(depth * 2, ' ') << test->getName() << "\n";
+ string name;
+
+ if (suite || m_longlist) {
+ // take the last component of the name and append to the parent
+ name = test->getName();
+ string::size_type i = name.find_last_of(".:");
+ name = parent + "." + (i != string::npos ? name.substr(i + 1) : name);
+
+ // drop the 1st component from the display and indent
+ if (parent != "") {
+ string::size_type j = i = name.find('.', 1);
+ while ((j = name.find('.', j + 1)) != string::npos)
+ cout << " ";
+ cout << " " << name.substr(i + 1) << "\n";
+ }
+ }
if (suite) {
typedef const vector<Test*> Tests;
Tests& tests = suite->getTests();
for (Iter it = tests.begin(); it != tests.end(); ++it)
- List(*it, depth + 1);
+ List(*it, name);
}
}