// File: /workspace/github_cpp_makefile_star2_O2/Jacobious52[P]Tanks/Test.cpp
// Function: test_array()
void test_array()
{
    // ---testing marray using pointers----

    printf("\nTesting array (of timers)..\n\n");
    MTArray array(5);
    assert(array.get_size() == 5, "init size");
    assert(array.get_count() == 0, "init count");

    array.add(new Timer(0, 0));
    assert(array.get_count() == 1, "count 1");

    array.add(new Timer(1, 1));
    Timer *t0 = new Timer(2, 2);
    array.add(t0);
    array.add(new Timer(3, 3));
    assert(array.get_count() == 4, "count 4");

    array.add(new Timer(4, 4));
    assert(array.get_count() == 5, "count 5");

    array.add(new Timer(5, 5));
    array.add(new Timer(6, 6));
    assert(array.get_count() == 7, "count 7");
    assert(array.get_size() == 10, "resized to 10");

    Timer *t1 = array.remove(2);
    assert(t1 == t0, "remove and return");
    delete t1;

    assert(array.get_count() == 6, "count 6");

    for (int i = 0; i < array.get_count(); ++i)
    {
        int d = i;
        if (i >= 2)
        {
            d += 1;
        }
        assert(array[i]->get_delay() == static_cast<double>(d), "iterating ");
        ConsoleTools::move_cursor(ConsoleTools::up , 1);
        ConsoleTools::move_cursor(ConsoleTools::right , StringTools::string_width("Passed: interating"));
        printf(": timer delay: %.2lf\n", array[i]->get_delay());
    }

    for (int i = 0; i < array.get_count(); ++i)
    {
        delete array.remove(i);
    }

    array.clear();
    assert(array.get_count() == 0, "clear");

    // -----test using int array------

    printf("\nTesting int array..\n\n");
    MutableArray<int> i_array(5);
    assert(i_array.get_size() == 5, "init size");
    assert(i_array.get_count() == 0, "init count");

    i_array.add(10);
    i_array.add(20);
    i_array.add(30);
    assert(i_array.get_count() == 3, "count 3");

    int x2 = i_array.remove(2);
    assert(x2 == 30, "remove and return");

    i_array.clear();
    assert(i_array.get_count() == 0, "clear");
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
leaq 0x200c(%rip), %rdi      # 0xb46a
callq 0x3360
andq $0x0, -0x40(%rbp)
pushq $0x5
popq %rax
movq %rax, -0x38(%rbp)
movq %rax, -0x30(%rbp)
pushq $0x28
popq %rdi
callq 0x3030
movq %rax, -0x48(%rbp)
leaq 0x1edc(%rip), %rsi      # 0xb362
pushq $0x1
popq %rdi
callq 0x9378
xorl %edi, %edi
cmpq $0x0, -0x40(%rbp)
sete %dil
leaq 0x1ecc(%rip), %rsi      # 0xb36c
callq 0x9378
pushq $0x20
popq %rdi
callq 0x3280
xorpd %xmm0, %xmm0
movupd %xmm0, 0x8(%rax)
andw $0x0, 0x18(%rax)
leaq -0x48(%rbp), %rdi
movq %rax, %rsi
callq 0xa25e
xorl %edi, %edi
cmpq $0x1, -0x40(%rbp)
sete %dil
leaq 0x1e9e(%rip), %rsi      # 0xb377
callq 0x9378
pushq $0x20
popq %rdi
callq 0x3280
movabsq $0x3ff0000000000000, %rcx # imm = 0x3FF0000000000000
movq %rcx, 0x8(%rax)
movq $0x1, 0x10(%rax)
andw $0x0, 0x18(%rax)
leaq -0x48(%rbp), %rdi
movq %rax, %rsi
callq 0xa25e
pushq $0x20
popq %rdi
callq 0x3280
movq %rax, %rbx
movabsq $0x4000000000000000, %rax # imm = 0x4000000000000000
movq %rax, 0x8(%rbx)
movq $0x2, 0x10(%rbx)
andw $0x0, 0x18(%rbx)
leaq -0x48(%rbp), %rdi
movq %rbx, %rsi
callq 0xa25e
pushq $0x20
popq %rdi
callq 0x3280
movabsq $0x4008000000000000, %rcx # imm = 0x4008000000000000
movq %rcx, 0x8(%rax)
movq $0x3, 0x10(%rax)
andw $0x0, 0x18(%rax)
leaq -0x48(%rbp), %rdi
movq %rax, %rsi
callq 0xa25e
xorl %edi, %edi
cmpq $0x4, -0x40(%rbp)
sete %dil
leaq 0x1dff(%rip), %rsi      # 0xb37f
callq 0x9378
pushq $0x20
popq %rdi
callq 0x3280
movabsq $0x4010000000000000, %rcx # imm = 0x4010000000000000
movq %rcx, 0x8(%rax)
movq $0x4, 0x10(%rax)
andw $0x0, 0x18(%rax)
leaq -0x48(%rbp), %rdi
movq %rax, %rsi
callq 0xa25e
xorl %edi, %edi
cmpq $0x5, -0x40(%rbp)
sete %dil
leaq 0x1dc1(%rip), %rsi      # 0xb387
callq 0x9378
pushq $0x20
popq %rdi
callq 0x3280
movabsq $0x4014000000000000, %rcx # imm = 0x4014000000000000
movq %rcx, 0x8(%rax)
movq $0x5, 0x10(%rax)
andw $0x0, 0x18(%rax)
leaq -0x48(%rbp), %rdi
movq %rax, %rsi
callq 0xa25e
pushq $0x20
popq %rdi
callq 0x3280
movabsq $0x4018000000000000, %rcx # imm = 0x4018000000000000
movq %rcx, 0x8(%rax)
movq $0x6, 0x10(%rax)
andw $0x0, 0x18(%rax)
leaq -0x48(%rbp), %rdi
movq %rax, %rsi
callq 0xa25e
xorl %edi, %edi
cmpq $0x7, -0x40(%rbp)
sete %dil
leaq 0x1d54(%rip), %rsi      # 0xb38f
callq 0x9378
xorl %edi, %edi
cmpq $0xa, -0x38(%rbp)
sete %dil
leaq 0x1d45(%rip), %rsi      # 0xb397
callq 0x9378
leaq -0x48(%rbp), %rdi
pushq $0x2
popq %rsi
callq 0xa296
movq %rax, %r14
xorl %edi, %edi
cmpq %rbx, %rax
sete %dil
leaq 0x1d2f(%rip), %rsi      # 0xb3a5
callq 0x9378
testq %r14, %r14
je 0x9684
andq $0x0, (%r14)
movq %r14, %rdi
callq 0x3260
xorl %edi, %edi
cmpq $0x6, -0x40(%rbp)
sete %dil
leaq 0x1d19(%rip), %rsi      # 0xb3b7
callq 0x9378
xorl %r12d, %r12d
leaq -0x88(%rbp), %r13
leaq -0x68(%rbp), %rbx
pushq $0x43
popq %r14
leaq 0x1d21(%rip), %r15      # 0xb3dd
movq -0x40(%rbp), %rax
cmpq %r12, %rax
jbe 0x9756
movq -0x48(%rbp), %rax
movq (%rax,%r12,8), %rdi
callq 0x8072
leal 0x1(%r12), %eax
cmpq $0x2, %r12
cmovbl %r12d, %eax
cvtsi2sd %eax, %xmm1
cmpeqsd %xmm1, %xmm0
movq %xmm0, %rdi
andl $0x1, %edi
leaq 0x1cc4(%rip), %rsi      # 0xb3bf
callq 0x9378
pushq $0x41
popq %rdi
pushq $0x1
popq %rsi
callq 0x38c8
movq %r13, %rdi
leaq 0x1cb5(%rip), %rsi      # 0xb3ca
movq %rbx, %rdx
callq 0x3120
movq %r13, %rdi
callq 0x66c8
movl %r14d, %edi
movl %eax, %esi
callq 0x38c8
movq %r13, %rdi
callq 0x32d0
movq -0x48(%rbp), %rax
movq (%rax,%r12,8), %rdi
callq 0x8072
movq %r15, %rdi
movb $0x1, %al
callq 0x3050
incq %r12
jmp 0x96bc
xorl %ebx, %ebx
leaq -0x48(%rbp), %r14
pushq $0x5
popq %r15
cmpq %rbx, %rax
jbe 0x978a
movq %r14, %rdi
movq %rbx, %rsi
callq 0xa296
testq %rax, %rax
je 0x9779
andq $0x0, (%rax)
movq %rax, %rdi
callq 0x3260
incq %rbx
movq -0x40(%rbp), %rax
jmp 0x9760
leaq -0x48(%rbp), %rbx
movq %rbx, %rdi
callq 0xa2cc
xorl %edi, %edi
cmpq $0x0, 0x8(%rbx)
sete %dil
leaq 0x1c4b(%rip), %rsi      # 0xb3f3
callq 0x9378
leaq 0x1cd4(%rip), %rdi      # 0xb488
callq 0x3360
andq $0x0, -0x60(%rbp)
movq %r15, -0x58(%rbp)
movq %r15, -0x50(%rbp)
pushq $0x14
popq %rdi
callq 0x3030
movq %rax, -0x68(%rbp)
leaq 0x1b89(%rip), %rsi      # 0xb362
pushq $0x1
popq %rdi
callq 0x9378
leaq 0x1b84(%rip), %rsi      # 0xb36c
pushq $0x1
popq %rdi
callq 0x9378
leaq -0x68(%rbp), %rdi
pushq $0xa
popq %rsi
callq 0xa304
leaq -0x68(%rbp), %rdi
pushq $0x14
popq %rsi
callq 0xa304
leaq -0x68(%rbp), %rdi
pushq $0x1e
popq %rsi
callq 0xa304
xorl %edi, %edi
cmpq $0x3, -0x60(%rbp)
sete %dil
leaq 0x1bd3(%rip), %rsi      # 0xb3f9
callq 0x9378
leaq -0x68(%rbp), %rdi
pushq $0x2
popq %rsi
callq 0xa33a
xorl %edi, %edi
cmpl $0x1e, %eax
sete %dil
leaq 0x1b5e(%rip), %rsi      # 0xb3a5
callq 0x9378
leaq -0x68(%rbp), %rbx
movq %rbx, %rdi
callq 0xa36c
xorl %edi, %edi
cmpq $0x0, 0x8(%rbx)
sete %dil
leaq 0x1b89(%rip), %rsi      # 0xb3f3
callq 0x9378
leaq -0x68(%rbp), %rdi
callq 0xa3a4
leaq -0x48(%rbp), %rdi
callq 0xa3b8
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x98c3
jmp 0x9896
jmp 0x98c3
movq %rax, %rbx
leaq -0x68(%rbp), %rdi
callq 0xa3a4
jmp 0x98c6
jmp 0x98c3
jmp 0x98c3
movq %rax, %rbx
leaq -0x88(%rbp), %rdi
callq 0x32d0
jmp 0x98c6
movq %rax, %rdi
callq 0x3a1e
jmp 0x98c3
movq %rax, %rbx
leaq -0x48(%rbp), %rdi
callq 0xa3b8
movq %rbx, %rdi
callq 0x33d0