C++ Library containing a lot of needful things: Stack Trace, Command Line Parser, Resource Handling, Configuration Files, Unix Command Execution, Directories, Regular Expressions, Tokenizer, Function Trace, Standard Extensions.
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
29 lines
877 B
29 lines
877 B
#include <mrw/exec.hpp> |
|
#include <mrw/stacktrace.hpp> |
|
#include <cppunit/TestFixture.h> |
|
#include <cppunit/ui/text/TestRunner.h> |
|
#include <cppunit/extensions/HelperMacros.h> |
|
#include <cppunit/extensions/TestFactoryRegistry.h> |
|
#include <string> |
|
|
|
class ExecTest: public CppUnit::TestFixture { |
|
public: |
|
void lsTest() { |
|
std::string res = (mrw::Cmd("/bin/ls"), "-l", "..").execute(); |
|
CPPUNIT_ASSERT(res.find("COPYING")<res.size()); |
|
} |
|
void excTest() { |
|
std::string res = (mrw::Cmd("/bin/false")).execute().result(); |
|
} |
|
CPPUNIT_TEST_SUITE(ExecTest); |
|
CPPUNIT_TEST(lsTest); |
|
CPPUNIT_TEST_EXCEPTION(excTest, mrw::ExecutionFailedExc); |
|
CPPUNIT_TEST_SUITE_END(); |
|
}; |
|
CPPUNIT_TEST_SUITE_REGISTRATION(ExecTest); |
|
|
|
int main() { |
|
CppUnit::TextUi::TestRunner runner; |
|
runner.addTest(CppUnit::TestFactoryRegistry::getRegistry().makeTest()); |
|
return runner.run() ? 0 : 1; |
|
}
|
|
|