ultimatepp/autotest/RangeInsertTest/RangeInsertTest.cpp
cxl 5200cdbee6 .autotest
git-svn-id: svn://ultimatepp.org/upp/trunk@9775 f0d560ea-af0d-0410-9eb7-867de7ffcac7
2016-05-03 07:56:43 +00:00

46 lines
944 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.Insert(pos, h);
a.Insert(pos, h);
iv.Insert(pos, h);
av.Insert(pos, h);
}
ASSERT(v == a);
ASSERT(v == iv);
ASSERT(v == av);
ASSERT(a == iv);
ASSERT(av == iv);
}
LOG("========== OK");
}