Rewrite wxPathList unit test without CppUnit-compatible API
Simplify the test by using a single function instead of all the machinery inherited from CppUnit. Also provide more information in case of test failure.
This commit is contained in:
@@ -18,44 +18,18 @@
|
|||||||
|
|
||||||
#include "wx/filefn.h"
|
#include "wx/filefn.h"
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
TEST_CASE("wxPathList::FindValidPath", "[file][path]")
|
||||||
// test class
|
|
||||||
// ----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
class PathListTestCase : public CppUnit::TestCase
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
PathListTestCase() { }
|
|
||||||
|
|
||||||
private:
|
|
||||||
CPPUNIT_TEST_SUITE( PathListTestCase );
|
|
||||||
CPPUNIT_TEST( FindValidPath );
|
|
||||||
CPPUNIT_TEST_SUITE_END();
|
|
||||||
|
|
||||||
void FindValidPath();
|
|
||||||
|
|
||||||
wxDECLARE_NO_COPY_CLASS(PathListTestCase);
|
|
||||||
};
|
|
||||||
|
|
||||||
// register in the unnamed registry so that these tests are run by default
|
|
||||||
CPPUNIT_TEST_SUITE_REGISTRATION( PathListTestCase );
|
|
||||||
|
|
||||||
// also include in its own registry so that these tests can be run alone
|
|
||||||
CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( PathListTestCase, "PathListTestCase" );
|
|
||||||
|
|
||||||
void PathListTestCase::FindValidPath()
|
|
||||||
{
|
{
|
||||||
#ifdef __UNIX__
|
#ifdef __UNIX__
|
||||||
#define CMD_IN_PATH wxT("ls")
|
#define CMD_IN_PATH "ls"
|
||||||
#else
|
#else
|
||||||
#define CMD_IN_PATH wxT("cmd.exe")
|
#define CMD_IN_PATH "cmd.exe"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
wxPathList pathlist;
|
wxPathList pathlist;
|
||||||
pathlist.AddEnvList(wxT("PATH"));
|
pathlist.AddEnvList(wxT("PATH"));
|
||||||
|
|
||||||
wxString path = pathlist.FindValidPath(CMD_IN_PATH);
|
wxString path = pathlist.FindValidPath(CMD_IN_PATH);
|
||||||
CPPUNIT_ASSERT( !path.empty() );
|
INFO( CMD_IN_PATH " not found in " << wxGetenv("PATH") );
|
||||||
|
CHECK( !path.empty() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user