#include "test.h" #include "util.h" using namespace mrbesen::util; int testStringSpliterator() { StringSpliterator spl("abc;def;ghi", ";"); ASSERT(spl, ""); ASSERT(*spl == "abc", *spl); ASSERT(*spl == "abc", *spl); ASSERT(spl, ""); spl++; ASSERT(spl, ""); ASSERT(*spl == "def", *spl); ASSERT(spl, ""); ++spl; ASSERT(*spl == "ghi", *spl); ASSERT(spl, ""); spl++; ASSERT(!spl, ""); StringSpliterator spl2(";abc;def;;ghi;", ";"); ASSERT(spl2, ""); ASSERT(*spl2 == "abc", *spl2); ASSERT(spl2, ""); spl2++; ASSERT(spl2, ""); ASSERT(*spl2 == "def", ""); ++spl2; //ASSERT(*spl2 == "ghi", *spl2); ASSERT(spl2, ""); spl2++; ASSERT(!spl2, ""); return TESTGOOD; } int testUtilSplit() { std::string test = ";abc;def;ghi;;"; std::string out[4]; unsigned int count = split(test, ";", out, 4); ASSERT(count == 3, count); ASSERT(out[0] == "abc", out[0]); ASSERT(out[1] == "def", out[1]); ASSERT(out[2] == "ghi", out[2]); test = "abc;;def;g;;hi"; count = split(test, ";;", out, 2); ASSERT(count == 2, count); ASSERT(out[0] == "abc", out[0]); //ASSERT(out[1] == "def;g;;hi", out[1]); ASSERT(out[1] == "def;g", out[1]); return TESTGOOD; }