59 lines
819 B
C++
59 lines
819 B
C++
#include "../random-access-containers/vector.hpp"
|
|
#include "testutil.hpp"
|
|
|
|
void FillWithSequentialNumbers(Vector<unsigned> & vector,
|
|
unsigned const count = 1024u)
|
|
{
|
|
for(unsigned i = 0; i < count; ++i)
|
|
{
|
|
vector[i] = i;
|
|
}
|
|
}
|
|
|
|
bool TestInsertion()
|
|
{
|
|
unsigned const targetSize = 1024u;
|
|
Vector<unsigned> vector;
|
|
try
|
|
{
|
|
vector.Resize(targetSize);
|
|
}
|
|
catch(std::exception & e)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
FillWithSequentialNumbers(vector, targetSize);
|
|
|
|
for(unsigned i = 0; i < vector.GetSize(); ++i)
|
|
{
|
|
if(vector[i] != i)
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
|
|
try
|
|
{
|
|
vector[targetSize + 1] = 42;
|
|
}
|
|
catch(std::exception & e)
|
|
{
|
|
return true;
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
bool TestResize()
|
|
{
|
|
return false;
|
|
}
|
|
|
|
int main()
|
|
{
|
|
Test::Execute(TestInsertion, "Insertion test");
|
|
Test::Execute(TestResize, "Resize test");
|
|
|
|
return 0;
|
|
} |