CoreUtils/testing/zstring_test.cpp
2023-10-05 17:57:01 -07:00

48 lines
1.4 KiB
C++

#include <iostream>
#include "../ZString.h"
int main(int argc, char **argv) {
// Test comparison operations.
coreutils::ZString test1("");
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;
}