ultimatepp/autotest/RangeInsertTest/RangeInsertTest.cpp
cxl 08f341ffee .autotest
git-svn-id: svn://ultimatepp.org/upp/trunk@9795 f0d560ea-af0d-0410-9eb7-867de7ffcac7
2016-05-04 07:34:57 +00:00

46 lines
964 B
C++

#include <Core/Core.h>
using namespace Upp;
CONSOLE_APP_MAIN
{
StdLogSetup(LOG_COUT|LOG_FILE);
SeedRandom();
Vector<int> v;
Array<int> a;
InVector<int> iv;
InArray<int> av;
for(int i = 0; i < 10000; i++) {
if(v.GetCount() > 100000) {
int pos = Random(v.GetCount() + 1);
int count = Random(v.GetCount() - pos);
LOG(i << ": removing " << pos << ", " << count);
v.Remove(pos, count);
a.Remove(pos, count);
iv.Remove(pos, count);
av.Remove(pos, count);
}
else {
Vector<int> h;
int count = Random(10000);
while(count--)
h << Random();
int pos = Random(v.GetCount() + 1);
LOG(i << ": inserting " << pos << ", " << h.GetCount());
v.InsertRange(pos, h);
a.InsertRange(pos, h);
iv.InsertRange(pos, h);
av.InsertRange(pos, h);
}
ASSERT(v == a);
ASSERT(v == iv);
ASSERT(v == av);
ASSERT(a == iv);
ASSERT(av == iv);
}
LOG("========== OK");
}