#include #include "../ZString.h" #include "../MString.h" int main(int argc, char **argv) { // Test floating point reader. coreutils::ZString pi("3.14159"); double x = pi.asDouble(); std::cout << "pi: " << x << std::endl; // 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; coreutils::ZString test5 = "this is a test of the Exclude tokenization without\n a line end."; coreutils::ZString test6 = test5.getTokenExclude("\n"); std::cout << test6 << std::endl; coreutils::ZString test7 = "this is a line\n \nthis is another line\n "; std::cout << test7.lineIsWhitespace() << test7.goeol() << std::endl; std::cout << test7.lineIsWhitespace() << test7.goeol() << std::endl; std::cout << test7.lineIsWhitespace() << test7.goeol() << std::endl; std::cout << test7.lineIsWhitespace() << test7.goeol() << std::endl; coreutils::ZString test8("value1"); coreutils::ZString test9("value2"); std::cout << test8.compare(test9) << ":" << test9.compare(test8) << ":" << test8.compare(test8) << std::endl; coreutils::ZString test10("value1"); coreutils::ZString test11("value1"); std::cout << test10.compare(test11) << ":" << test11.compare(test10) << std::endl; coreutils::ZString test12("1"); coreutils::ZString test13("12"); std::cout << (test12 < test13) << ":" << (test13 < test12) << std::endl; coreutils::ZString test14("25.5"); coreutils::ZString test15("xyx"); std::cout << test14.startsWithDouble() << ":" << test15.startsWithDouble() << std::endl; coreutils::ZString test16("This is a test of substring"); std::cout << test16.substring(10) << std::endl; std::cout << test16.substring(10, 4) << std::endl; std::cout << test16.substring(0, 7) << std::endl; std::cout << test16.substring(18, 20) << std::endl; coreutils::ZString test17(" hello there "); std::cout << "[" << test17.trim() << "]" << std::endl; coreutils::ZString test18("this.test"); std::cout << "[" << test18.find(".") << "] " << test18.parsed() << ":" << test18.unparsed() << std::endl; test18.reset(); std::cout << "[" << test18.find("x") << "] " << test18.parsed() << ":" << test18.unparsed() << std::endl; coreutils::ZString test19("-16473.65476Z"); std::cout << test19.asDouble() << ":" << test19.unparsed() << std::endl; }