module tests.vector;

import bubel.ecs.simple_vector;
//import bubel.ecs.vector;

@("simple-vector")
unittest
{
    SimpleVector vector;
    vector.add(cast(ubyte[]) "a");
    vector.add(cast(ubyte[]) "bsdf");
    assert(vector[0 .. 5] == cast(ubyte[]) "absdf");
    assert(vector[4] == 'f');
    assert(vector[] == cast(ubyte[]) "absdf");
    assert(vector[$ - 1] == 'f');

    vector.clear();
    assert(vector.length == 0);

    ubyte[1025] array;
    foreach(i;0..cast(uint)array.length)array[i] = cast(ubyte)i;
    vector.add(array);
    assert(vector.length == 1025);
    assert(vector[] == array[]);

    SimpleVector vector2;
    vector2.clear();
    vector2.add(array[0..1023]);
    vector2.add('a');
    vector2.add('b');
    assert(vector2.length == 1025);
    assert(vector2[0..1023] == array[0..1023]);
    assert(vector2[1023] == 'a');
    assert(vector2[1024] == 'b');
}
