58 lines
1.7 KiB
C++
58 lines
1.7 KiB
C++
#include <iostream>
|
|
#include "../ZString.h"
|
|
#include "../MString.h"
|
|
|
|
int main(int argc, char **argv) {
|
|
|
|
// Test comparison operations.
|
|
|
|
coreutils::ZString test1("else");
|
|
std::cout << (test1 != ".") << std::endl;
|
|
std::cout << (test1 == "") << std::endl;
|
|
|
|
// Test constructors.
|
|
|
|
coreutils::ZString test3("1659979856.747021214|barant@barant");
|
|
std::cout << test3 << std::endl;
|
|
|
|
// Test split operations.
|
|
|
|
coreutils::ZString test("11111:22222:33333:44444");
|
|
std::cout << "test pre-split: [" << test << "]." << std::endl;
|
|
|
|
test.split(":", 1);
|
|
|
|
std::cout << "test post-split: [" << test << "]." << std::endl;
|
|
std::cout << "test sections: [" << test.getList().size() << "]." << std::endl;
|
|
std::cout << test.getLength() << std::endl;
|
|
|
|
for(int ix = 0; ix < test.getList().size(); ++ix)
|
|
std::cout << ix << ":" << test[ix] << std::endl;
|
|
|
|
// Test substring operations.
|
|
|
|
coreutils::ZString test2("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ");
|
|
std::cout << "substring: [" << test2.substring(10) << "]" << std::endl;
|
|
|
|
// Test getContainer.
|
|
|
|
coreutils::ZString test4("test(this is a container (with a nesting))012345");
|
|
test4.getTokenExclude("(");
|
|
std::cout << "container: " << test4.getContainer() << std::endl;
|
|
std::cout << "rest: " << test4.unparsed() << std::endl;
|
|
|
|
// Test find();
|
|
coreutils::ZString testA("this is a test string for MX 250xyzabc");
|
|
std::cout << "find MX: " << testA.find("MX") << std::endl;
|
|
std::cout << "unparsed: " << testA.unparsed() << std::endl;
|
|
|
|
std::string testb = "this is a string";
|
|
coreutils::ZString testc = testb;
|
|
std::cout << testc << std::endl;
|
|
|
|
coreutils::MString testd = "this is an mstring";
|
|
testc = testd;
|
|
std::cout << testc << std::endl;
|
|
|
|
}
|