// File: /workspace/github_c_makefile_star2_O1/chatziko-k08[P]lecture-code/tests/ADTVector_test.c
// Function: test_iterate
void test_iterate(void) {
	Vector vec = vector_create(0, NULL);
	int N = 1000;
	int* array = malloc(N * sizeof(*array));		// Στο vector θα προσθέσουμε pointers προς τα στοιχεία αυτού του πίνακα

	// first/last σε κενό vector
	TEST_ASSERT(vector_first(vec) == VECTOR_BOF);
	TEST_ASSERT(vector_last(vec) == VECTOR_EOF);

	// εισαγωγή στοιχείων
	for (int i = 0; i < 1000; i++)
		vector_insert_last(vec, &array[i]);

	int i = 0;
	for (VectorNode node = vector_first(vec); node != VECTOR_EOF; node = vector_next(vec, node))
		TEST_ASSERT(vector_node_value(vec, node) == &array[i++]);
	TEST_ASSERT(i == N);

	for (VectorNode node = vector_last(vec); node != VECTOR_BOF; node = vector_previous(vec, node))
		TEST_ASSERT(vector_node_value(vec, node) == &array[--i]);
	TEST_ASSERT(i == 0);

	vector_destroy(vec);
	free(array);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
xorl %edi, %edi
xorl %esi, %esi
callq 0x4bb8
movq %rax, %rbx
movl $0xfa0, %edi            # imm = 0xFA0
callq 0x21a0
movq %rax, %r12
movq %rbx, %rdi
callq 0x4de6
xorl %edi, %edi
testq %rax, %rax
sete %dil
leaq 0x10d9(%rip), %rsi      # 0x5318
leaq 0x13c0(%rip), %rcx      # 0x5606
leaq 0x1191(%rip), %r8       # 0x53de
movl $0x5d, %edx
xorl %eax, %eax
callq 0x25cc
testl %eax, %eax
je 0x442b
movq %rbx, %rdi
callq 0x4df3
xorl %edi, %edi
testq %rax, %rax
sete %dil
leaq 0x109f(%rip), %rsi      # 0x5318
leaq 0x1386(%rip), %rcx      # 0x5606
leaq 0x1177(%rip), %r8       # 0x53fe
movl $0x5e, %edx
xorl %eax, %eax
callq 0x25cc
testl %eax, %eax
je 0x442b
xorl %r14d, %r14d
leaq (%r12,%r14), %rsi
movq %rbx, %rdi
callq 0x4c89
addq $0x4, %r14
cmpq $0xfa0, %r14            # imm = 0xFA0
jne 0x429e
movq %rbx, %rdi
callq 0x4de6
testq %rax, %rax
movq %r12, (%rsp)
je 0x432d
movq %rax, %r15
leaq 0x1334(%rip), %r13      # 0x5606
leaq 0x1144(%rip), %rbp      # 0x541d
xorl %r14d, %r14d
movq %rbx, %rdi
movq %r15, %rsi
callq 0x4e36
xorl %edi, %edi
cmpq %rax, %r12
sete %dil
leaq 0x1021(%rip), %rsi      # 0x5318
movl $0x66, %edx
movq %r13, %rcx
movq %rbp, %r8
xorl %eax, %eax
callq 0x25cc
testl %eax, %eax
je 0x442b
movq %rbx, %rdi
movq %r15, %rsi
callq 0x4e0b
movq %rax, %r15
addq $0x4, %r12
incl %r14d
testq %rax, %rax
jne 0x42dc
jmp 0x4330
xorl %r14d, %r14d
xorl %edi, %edi
cmpl $0x3e8, %r14d           # imm = 0x3E8
sete %dil
leaq 0xfd4(%rip), %rsi       # 0x5318
leaq 0x12bb(%rip), %rcx      # 0x5606
leaq 0x10f7(%rip), %r8       # 0x5449
movl $0x67, %edx
xorl %eax, %eax
callq 0x25cc
testl %eax, %eax
je 0x442b
movq %rbx, %rdi
callq 0x4df3
testq %rax, %rax
movq (%rsp), %rcx
je 0x43de
movq %rax, %r15
movslq %r14d, %rax
leaq (%rcx,%rax,4), %r12
addq $-0x4, %r12
leaq 0x127a(%rip), %r13      # 0x5606
leaq 0x10bd(%rip), %rbp      # 0x5450
movq %rbx, %rdi
movq %r15, %rsi
callq 0x4e36
xorl %edi, %edi
cmpq %rax, %r12
sete %dil
leaq 0xf6a(%rip), %rsi       # 0x5318
movl $0x6a, %edx
movq %r13, %rcx
movq %rbp, %r8
xorl %eax, %eax
callq 0x25cc
testl %eax, %eax
je 0x442b
movq %rbx, %rdi
movq %r15, %rsi
callq 0x4e28
movq %rax, %r15
decl %r14d
addq $-0x4, %r12
testq %rax, %rax
jne 0x4393
xorl %edi, %edi
testl %r14d, %r14d
sete %dil
leaq 0xf2a(%rip), %rsi       # 0x5318
leaq 0x1211(%rip), %rcx      # 0x5606
leaq 0x1080(%rip), %r8       # 0x547c
movl $0x6b, %edx
xorl %eax, %eax
callq 0x25cc
testl %eax, %eax
je 0x442b
movq %rbx, %rdi
callq 0x4da2
movq (%rsp), %rdi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x22a0
callq 0x2e13