pathlist.cpp 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. ///////////////////////////////////////////////////////////////////////////////
  2. // Name: tests/misc/pathlist.cpp
  3. // Purpose: Test wxPathList
  4. // Author: Francesco Montorsi (extracted from console sample)
  5. // Created: 2010-06-02
  6. // Copyright: (c) 2010 wxWidgets team
  7. ///////////////////////////////////////////////////////////////////////////////
  8. // ----------------------------------------------------------------------------
  9. // headers
  10. // ----------------------------------------------------------------------------
  11. #include "testprec.h"
  12. #ifdef __BORLANDC__
  13. # pragma hdrstop
  14. #endif
  15. #include "wx/filefn.h"
  16. // ----------------------------------------------------------------------------
  17. // test class
  18. // ----------------------------------------------------------------------------
  19. class PathListTestCase : public CppUnit::TestCase
  20. {
  21. public:
  22. PathListTestCase() { }
  23. private:
  24. CPPUNIT_TEST_SUITE( PathListTestCase );
  25. CPPUNIT_TEST( FindValidPath );
  26. CPPUNIT_TEST_SUITE_END();
  27. void FindValidPath();
  28. DECLARE_NO_COPY_CLASS(PathListTestCase)
  29. };
  30. // register in the unnamed registry so that these tests are run by default
  31. CPPUNIT_TEST_SUITE_REGISTRATION( PathListTestCase );
  32. // also include in its own registry so that these tests can be run alone
  33. CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( PathListTestCase, "PathListTestCase" );
  34. void PathListTestCase::FindValidPath()
  35. {
  36. #ifdef __UNIX__
  37. #define CMD_IN_PATH wxT("ls")
  38. #else
  39. #define CMD_IN_PATH wxT("cmd.exe")
  40. #endif
  41. wxPathList pathlist;
  42. pathlist.AddEnvList(wxT("PATH"));
  43. wxString path = pathlist.FindValidPath(CMD_IN_PATH);
  44. CPPUNIT_ASSERT( !path.empty() );
  45. }