From a21abf533d8171d7de3065679f6912c2ed47412b Mon Sep 17 00:00:00 2001 From: cxl Date: Sun, 27 Nov 2016 15:16:36 +0000 Subject: [PATCH] .autotest git-svn-id: svn://ultimatepp.org/upp/trunk@10495 f0d560ea-af0d-0410-9eb7-867de7ffcac7 --- autotest/CoAlgo/CoAlgo.cpp | 16 ++++++++++++++++ autotest/PcreTest/PcreTest.cpp | 25 ++++++++++++++++++++----- autotest/RangeCoLoop/RangeCoLoop.cpp | 24 +++++++++++++++++++++++- 3 files changed, 59 insertions(+), 6 deletions(-) diff --git a/autotest/CoAlgo/CoAlgo.cpp b/autotest/CoAlgo/CoAlgo.cpp index 42e1f4b01..16770ae2a 100644 --- a/autotest/CoAlgo/CoAlgo.cpp +++ b/autotest/CoAlgo/CoAlgo.cpp @@ -23,5 +23,21 @@ CONSOLE_APP_MAIN ASSERT(Count(h, 200) == CoCount(h, 200)); ASSERT(CountIf(h, [](auto x) { return x % 17 == 0; }) == CoCountIf(h, [](auto x) { return x % 17 == 0; })); + Vector a; + Array b; + for(int i = 0; i < 10000000; i++) { + int x = Random(10000); + a.Add(x); + b.Add(x); + } + + ASSERT(IsEqualRange(a, b)); + ASSERT(CoIsEqualRange(a, b)); + + a[a.GetCount() - a.GetCount() / 7]++; + + ASSERT(!IsEqualRange(a, b)); + ASSERT(!CoIsEqualRange(a, b)); + LOG("============ OK"); } diff --git a/autotest/PcreTest/PcreTest.cpp b/autotest/PcreTest/PcreTest.cpp index ac3dc84ec..661795792 100644 --- a/autotest/PcreTest/PcreTest.cpp +++ b/autotest/PcreTest/PcreTest.cpp @@ -5,23 +5,38 @@ using namespace Upp; CONSOLE_APP_MAIN { + StdLogSetup(LOG_COUT|LOG_FILE); + RegExp r0("(\\w+)\\s(\\w+)\\s(\\w+)"); if(r0.Match("one two three")) { for(int i = 0; i < r0.GetCount(); i++) - Cout() << r0[i] << '\n'; + DUMP(r0[i]); } else if(r0.IsError()) - Cout() << r0.GetError() << '\n'; + DUMP(r0.GetError()); + ASSERT(!r0.IsError()); - Cout() << "------------------------------\n"; + LOG("=================================="); RegExp r1("(\\w+)", RegExp::UNICODE); int i = 0; while(r1.GlobalMatch("hello 4 ho 55 uuu iii pp 99 baby too swistak")) { for(int i = 0; i < r1.GetCount(); i++) - Cout() << r1[i] << '\n'; + DUMP(r1[i]); } if(r1.IsError()) - Cout() << r1.GetError() << '\n'; + DUMP(r1.IsError()); + ASSERT(!r1.IsError()); + + RegExp re( + "(stuff)\\s+(\\d+)?\\s*(stuffx)?\\s*([a-zA-Z_][a-zA-Z0-9_-]*=(?:\".*\"|\'.*\'|[[:graph:]]*) )*\\s*(\".*?\");" + "|(stuff2)\\s+(\".*?\");" + "|(stuff3)\\s+(\".*?\".*?);" + "|(.*?);" + ); + ASSERT(re.Match("tid nanu;")); + ASSERT(!re.IsError()); + + LOG("========================= OK"); } diff --git a/autotest/RangeCoLoop/RangeCoLoop.cpp b/autotest/RangeCoLoop/RangeCoLoop.cpp index 82fce2066..c2a45988a 100644 --- a/autotest/RangeCoLoop/RangeCoLoop.cpp +++ b/autotest/RangeCoLoop/RangeCoLoop.cpp @@ -34,5 +34,27 @@ CONSOLE_APP_MAIN { ASSERT(sum = Sum(x)); - LOG("=================== OK"); + SeedRandom(); + + for(int ii = 0; ii < 200; ii++) { + DUMP(ii); + int N = Random(20000000); + int mod = 6 * Random(50000) + 1; + int from = Random(N); + DUMP(N); + DUMP(mod); + DUMP(from); + Vector data; + for(int i = 0; i < N; i++) + data.Add(Random()); + + auto f = FindAll(data, [=](int c) { return c % mod == 0; }, from); + auto cf = CoFindAll(data, [=](int c) { return c % mod == 0; }, from); + DUMP(f.GetCount()); + DUMP(cf.GetCount()); + ASSERT(f == cf); + LOG("================"); + } + + LOG("===================== OK in " << tm); }