// File: /workspace/github_c_makefile_star2_O2/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 0x4804
movq %rax, %rbx
movl $0xfa0, %edi            # imm = 0xFA0
callq 0x21a0
movq %rax, %rbp
movq %rbx, %rdi
callq 0x4a1a
xorl %edi, %edi
testq %rax, %rax
sete %dil
leaq 0x1439(%rip), %rsi      # 0x5318
leaq 0x171d(%rip), %rcx      # 0x5603
leaq 0x14f1(%rip), %r8       # 0x53de
pushq $0x5d
popq %rdx
xorl %eax, %eax
callq 0x239c
testl %eax, %eax
je 0x40ad
movq %rbx, %rdi
callq 0x4a27
xorl %edi, %edi
testq %rax, %rax
sete %dil
leaq 0x1401(%rip), %rsi      # 0x5318
leaq 0x16e5(%rip), %rcx      # 0x5603
leaq 0x14d9(%rip), %r8       # 0x53fe
pushq $0x5e
popq %rdx
xorl %eax, %eax
callq 0x239c
testl %eax, %eax
je 0x40ad
xorl %r14d, %r14d
cmpq $0xfa0, %r14            # imm = 0xFA0
je 0x3f55
leaq (%r14,%rbp), %rsi
movq %rbx, %rdi
callq 0x48cb
addq $0x4, %r14
jmp 0x3f3a
movq %rbx, %rdi
callq 0x4a1a
movq %rax, %r15
leaq 0x14b6(%rip), %r12      # 0x541d
pushq $0x66
popq %r14
movq %rbp, (%rsp)
xorl %r13d, %r13d
testq %r15, %r15
je 0x3fc5
movq %rbx, %rdi
movq %r15, %rsi
callq 0x4a6a
xorl %edi, %edi
cmpq %rax, %rbp
sete %dil
leaq 0x1386(%rip), %rsi      # 0x5318
movl %r14d, %edx
leaq 0x1667(%rip), %rcx      # 0x5603
movq %r12, %r8
xorl %eax, %eax
callq 0x239c
testl %eax, %eax
je 0x40ad
movq %rbx, %rdi
movq %r15, %rsi
callq 0x4a3f
movq %rax, %r15
decq %r13
addq $0x4, %rbp
jmp 0x3f72
xorl %edi, %edi
cmpq $-0x3e8, %r13           # imm = 0xFC18
sete %dil
leaq 0x133f(%rip), %rsi      # 0x5318
leaq 0x1623(%rip), %rcx      # 0x5603
leaq 0x1462(%rip), %r8       # 0x5449
pushq $0x67
popq %rdx
xorl %eax, %eax
callq 0x239c
testl %eax, %eax
je 0x40ad
addq $-0x4, %rbp
movq %rbx, %rdi
callq 0x4a27
movq %rax, %r12
leaq 0x1441(%rip), %r15      # 0x5450
pushq $0x6a
popq %r14
testq %r12, %r12
je 0x4062
movq %rbx, %rdi
movq %r12, %rsi
callq 0x4a6a
xorl %edi, %edi
cmpq %rax, %rbp
sete %dil
leaq 0x12e5(%rip), %rsi      # 0x5318
movl %r14d, %edx
leaq 0x15c6(%rip), %rcx      # 0x5603
movq %r15, %r8
xorl %eax, %eax
callq 0x239c
testl %eax, %eax
je 0x40ad
movq %rbx, %rdi
movq %r12, %rsi
callq 0x4a5c
movq %rax, %r12
incq %r13
addq $-0x4, %rbp
jmp 0x4013
xorl %edi, %edi
testq %r13, %r13
sete %dil
leaq 0x12a6(%rip), %rsi      # 0x5318
leaq 0x158a(%rip), %rcx      # 0x5603
leaq 0x13fc(%rip), %r8       # 0x547c
pushq $0x6b
popq %rdx
xorl %eax, %eax
callq 0x239c
testl %eax, %eax
je 0x40ad
movq %rbx, %rdi
callq 0x49da
movq (%rsp), %rdi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x22a0
callq 0x2bc0