From 46173bbb169cab45e7d88a352a3f3ee7cbdfb171 Mon Sep 17 00:00:00 2001 From: cxl Date: Thu, 18 Jun 2020 06:39:20 +0000 Subject: [PATCH] .autotest git-svn-id: svn://ultimatepp.org/upp/trunk@14608 f0d560ea-af0d-0410-9eb7-867de7ffcac7 --- autotest/SplitJoin/SplitJoin.cpp | 20 ++++++++++--------- autotest/decode/decode.cpp | 34 ++++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+), 9 deletions(-) diff --git a/autotest/SplitJoin/SplitJoin.cpp b/autotest/SplitJoin/SplitJoin.cpp index 99d42a9ae..591968617 100644 --- a/autotest/SplitJoin/SplitJoin.cpp +++ b/autotest/SplitJoin/SplitJoin.cpp @@ -112,17 +112,19 @@ CONSOLE_APP_MAIN String a, b, c; - TEST2(SplitTo("one", ',', a, b, c), 0); - TEST2(SplitTo("one,two,,three", ',', a, b, c), 0); - TEST2(SplitTo("one,two,,three", ',', false, a, b, c), 0); + TEST2(SplitTo("one", ',', a, b, c), "false:::"); + TEST2(SplitTo("one,two,,three", ',', a, b, c), "true:one:two:three"); + TEST2(SplitTo("one,two,,three", ',', false, a, b, c), "true:one:two:"); - TEST2(SplitTo("one", ",", a, b, c), 0); - TEST2(SplitTo("one,two,,three", ",", a, b, c), 0); - TEST2(SplitTo("one,two,,three", ",", false, a, b, c), 0); + a = b = c = Null; + TEST2(SplitTo("one", ",", a, b, c), "false:::"); + TEST2(SplitTo("one,two,,three", ",", a, b, c), "true:one:two:three"); + TEST2(SplitTo("one,two,,three", ",", false, a, b, c), "true:one:two:"); - TEST2(SplitTo("one", CharFilterComma, a, b, c), 0); - TEST2(SplitTo("one,two,,three", CharFilterComma, a, b, c), 0); - TEST2(SplitTo("one,two,,three", CharFilterComma, false, a, b, c), 0); + a = b = c = Null; + TEST2(SplitTo("one", CharFilterComma, a, b, c), "false:::"); + TEST2(SplitTo("one,two,,three", CharFilterComma, a, b, c), "true:one:two:three"); + TEST2(SplitTo("one,two,,three", CharFilterComma, false, a, b, c), "true:one:two:"); LOG("===================== OK"); } diff --git a/autotest/decode/decode.cpp b/autotest/decode/decode.cpp index 5899febf9..0c06aafc9 100644 --- a/autotest/decode/decode.cpp +++ b/autotest/decode/decode.cpp @@ -4,6 +4,8 @@ using namespace Upp; CONSOLE_APP_MAIN { + StdLogSetup(LOG_COUT|LOG_FILE); + ASSERT(decode(0, 1, "one", 2, "two", 3, "three", "unknown") == String("unknown")); ASSERT(decode(1, 1, "one", 2, "two", 3, "three", "unknown") == String("one")); ASSERT(decode(2, 1, "one", 2, "two", 3, "three", "unknown") == String("two")); @@ -11,8 +13,30 @@ CONSOLE_APP_MAIN ASSERT(decode(3, 1, "one", 2, "two", 3.0, "three", "unknown") == String("three")); ASSERT(decode(4, 1, "one", 2, "two", 3, "three", "unknown") == String("unknown")); + ASSERT(decode(0, 1, 11, 2, 12, 3, 13, 14) == 14); + ASSERT(decode(1, 1, 11, 2, 12, 3, 13, 14) == 11); + ASSERT(decode(2, 1, 11, 2, 12, 3, 13, 14) == 12); + ASSERT(decode(3, 1, 11, 2, 12, 3, 13, 14) == 13); + ASSERT(decode(3, 1, 11, 2, 12, 3.0, 13, 14) == 13); + ASSERT(decode(4, 1, 11, 2, 12, 3, 13, 14) == 14); + + ASSERT(get_i(-1, "one", "two", "three") == String("one")); + ASSERT(get_i(0, "one", "two", "three") == String("one")); + ASSERT(get_i(1, "one", "two", "three") == String("two")); + ASSERT(get_i(2, "one", "two", "three") == String("three")); + ASSERT(get_i(3, "one", "two", "three") == String("three")); + ASSERT(get_i(30, "one", "two", "three") == String("three")); + + ASSERT(get_i(-1, 1, 2, 3) == 1); + ASSERT(get_i(0, 1, 2, 3) == 1); + ASSERT(get_i(1, 1, 2, 3) == 2); + ASSERT(get_i(2, 1, 2, 3) == 3); + ASSERT(get_i(3, 1, 2, 3) == 3); + ASSERT(get_i(30, 1, 2, 3) == 3); + String s = "3"; ASSERT(findarg(s, "0", "1", "2", "3") == 3); + ASSERT(findarg("a", "0", "1", "2", "3") == -1); ASSERT(decode(s, "3", 3, -1) == 3); ASSERT(decode(s, "4", 3, -1) == -1); @@ -40,4 +64,14 @@ CONSOLE_APP_MAIN ASSERT(max(0, 1, 0, 0) == 1); ASSERT(max(0, 0, 1, 0) == 1); ASSERT(max(0, 0, 0, 1) == 1); + + ASSERT(gather>("1", "2", "3") == Vector({ "1", "2", "3" })); + + int a, b, c; + scatter(Vector({11, 22, 33}), a, b, c); + ASSERT(a == 11); + ASSERT(b == 22); + ASSERT(c == 33); + + LOG("=============== OK"); }