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.
50 lines
1.3 KiB
50 lines
1.3 KiB
18 years ago
|
/** @file
|
||
|
|
||
|
$Id$
|
||
|
|
||
|
$Date$
|
||
|
$Author$
|
||
|
|
||
|
@copy © Marc Wäckerlin
|
||
|
@license LGPL, see file <a href="license.html">COPYING</a>
|
||
|
|
||
|
$Log$
|
||
|
|
||
|
1 2 3 4 5 6 7 8
|
||
|
5678901234567890123456789012345678901234567890123456789012345678901234567890
|
||
|
*/
|
||
|
#include <mrw/string.hpp>
|
||
|
#include <mrw/list.hpp>
|
||
|
#include <algorithm>
|
||
|
|
||
|
#include <cppunit/TestFixture.h>
|
||
|
#include <cppunit/ui/text/TestRunner.h>
|
||
|
#include <cppunit/extensions/HelperMacros.h>
|
||
|
#include <cppunit/extensions/TestFactoryRegistry.h>
|
||
|
|
||
|
class StringTest: public CppUnit::TestFixture {
|
||
|
public:
|
||
|
void Join() {
|
||
|
std::list<std::string> l;
|
||
|
l<<"Hello"<<"World"<<"here"<<"I"<<"am";
|
||
|
CPPUNIT_ASSERT(mrw::join(l)=="Hello World here I am");
|
||
|
}
|
||
|
void Split() {
|
||
|
std::string text("Hello World here I am");
|
||
|
std::list<std::string> a(mrw::split(text)), b;
|
||
|
b<<"Hello"<<"World"<<"here"<<"I"<<"am";
|
||
|
CPPUNIT_ASSERT(equal(a.begin(), a.end(), b.begin()));
|
||
|
}
|
||
|
CPPUNIT_TEST_SUITE(StringTest);
|
||
|
CPPUNIT_TEST(Join);
|
||
|
CPPUNIT_TEST(Split);
|
||
|
CPPUNIT_TEST_SUITE_END();
|
||
|
};
|
||
|
CPPUNIT_TEST_SUITE_REGISTRATION(StringTest);
|
||
|
|
||
|
int main() {
|
||
|
CppUnit::TextUi::TestRunner runner;
|
||
|
runner.addTest(CppUnit::TestFactoryRegistry::getRegistry().makeTest());
|
||
|
return runner.run() ? 0 : 1;
|
||
|
}
|