mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-05-15 14:16:07 -06:00
.autotest
git-svn-id: svn://ultimatepp.org/upp/trunk@10495 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
a772f7c3fa
commit
a21abf533d
3 changed files with 59 additions and 6 deletions
|
|
@ -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<int> a;
|
||||
Array<int> 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");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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<int> 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);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue