#include "../../../gen/l1/VecAndSpan_U8.h"
#include "../../../gen/l1/VecAndSpan_U32.h"

int main() {
    VecU8 a = VecU8_new();
    VecU8_append(&a, 116);
    assert(a.len == 1);
    assert(a.capacity == 1);
    VecU8_append(&a, 18);
    assert(a.len == 2);
    assert(a.capacity == 2);
    VecU8_append(&a, 180);
    assert(a.len == 3);
    assert(a.capacity == 4);
    VecU8_append(&a, 9);
    assert(a.len == 4);
    assert(a.capacity == 4);
    VecU8_append(&a, 90);
    assert(a.len == 5);
    assert(a.capacity == 8);
    assert(*VecU8_at(&a, 0) == 116);
    assert(*VecU8_at(&a, 1) == 18);
    assert(*VecU8_at(&a, 2) == 180);
    assert(*VecU8_at(&a, 3) == 9);
    assert(*VecU8_at(&a, 4) == 90);
    VecU8_drop(a);

    VecU32 b = VecU32_new_filled(3, 5);
    assert(b.len == 3);
    assert(b.capacity == 3);
    VecU32_append(&b, 41);
    assert(b.len == 4);
    assert(b.capacity == 6);

    VecU32 c = VecU32_new();
    VecU32_append(&c, 5);
    VecU32_append(&c, 5);
    VecU32_append(&c, 5);
    VecU32_append(&c, 41);
    assert(VecU32_equal_VecU32(&b, &c));
    VecU32_append(&c, 7);
    assert(!VecU32_equal_VecU32(&b, &c));
    U32 x = VecU32_pop(&c);
    assert(x == 7);
    assert(VecU32_equal_VecU32(&b, &c));
    // Now b = c = [5, 5, 5, 7]
    for (int i = 0; i < 4; i++) {
        printf("%u  %u\n", *VecU32_at(&b, i), *VecU32_at(&c, i));
    }

    *VecU32_mat(&b, 3) = 17;
    assert(!VecU32_equal_VecU32(&b, &c));
    *VecU32_mat(&c, 3) = 17;
    assert(VecU32_equal_VecU32(&b, &c));

    MutSpanU32 s0 = VecU32_mspan(&c, 4, 0);
    MutSpanU32 s1 = VecU32_mspan(&c, 3, 1);
    MutSpanU32 s2 = VecU32_mspan(&c, 2, 2);
    MutSpanU32 s3 = VecU32_mspan(&c, 1, 3);
    MutSpanU32 s4 = VecU32_mspan(&c, 0, 4);
    assert(*MutSpanU32_at(s4, 3) == 17);
    for (size_t i = 0; i < 3; i++) {
        *VecU32_mat(&c, i) = i;
    }
    *MutSpanU32_at(s3, 2) = 3;
    assert(*MutSpanU32_at(s1, 0) == 3);
    assert(*MutSpanU32_at(s2, 0) == 2);
    assert(*MutSpanU32_at(s3, 0) == 1);
    assert(*MutSpanU32_at(s4, 0) == 0);
    VecU32 d = VecU32_clone(&c);
    VecU32 e = VecU32_clone(&c);
    VecU32_append(&c, 50);
    VecU32_append(&e, 500);
    assert(d.len == 4);
    assert(d.capacity == 4);
    assert(c.len == 5);
    for (int i = 0; i < 4; i++) {
        VecU32_pop(&d);
    }
    assert(*VecU32_at(&e, 4) == 500);

    VecU32_drop(e);
    VecU32_drop(d);
    VecU32_drop(c);
    VecU32_drop(b);
    return 0;
}
