// File: rocket323[P]fishdb/tests/test_main.cpp
// Function: test_pager()
MU_TEST(test_pager)
{
    Pager pager;
    int ret = pager.Init("test1.fdb");
    if (ret != 0)
    {
        printf("open test1.fdb failed\n");
        return;
    }
    srand(time(NULL));

    int N = 2;
    std::vector<int64_t> pgno;
    for (int i = 0; i < N; ++i)
    {
        auto mp = pager.NewPage();
        pgno.push_back(mp->header.page_no);
        FillPage(mp);
    }

    pager.Prune(0, true);

    for (int i = 0; i < (int)pgno.size(); ++i)
    {
        auto mp = pager.GetPage(pgno[i]);
        printf("children_size[%zu], kvs_size[%zu]\n", mp->children.size(), mp->kvs.size());
        assert((int)mp->children.size() == ks);
        assert((int)mp->kvs.size() == ks);
    }

    pager.Close();
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x120, %rsp            # imm = 0x120
leaq -0x48(%rbp), %rdi
callq 0x5920
leaq -0x71(%rbp), %rdi
movq %rdi, -0xf0(%rbp)
callq 0x3440
movq -0xf0(%rbp), %rdx
leaq 0x10c01(%rip), %rsi     # 0x151d3
leaq -0x70(%rbp), %rdi
callq 0x3350
jmp 0x45dd
leaq -0x48(%rbp), %rdi
leaq -0x70(%rbp), %rsi
callq 0x10490
movl %eax, -0xf4(%rbp)
jmp 0x45f2
leaq -0x70(%rbp), %rdi
callq 0x3160
leaq -0x71(%rbp), %rdi
callq 0x32b0
movl -0xf4(%rbp), %eax
movl %eax, -0x4c(%rbp)
cmpl $0x0, -0x4c(%rbp)
je 0x467d
leaq 0x10bc3(%rip), %rdi     # 0x151dd
xorl %eax, %eax
callq 0x3050
jmp 0x4623
movl $0x1, -0x88(%rbp)
jmp 0x4942
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
jmp 0x465b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
leaq -0x70(%rbp), %rdi
callq 0x3160
leaq -0x71(%rbp), %rdi
callq 0x32b0
jmp 0x4960
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
jmp 0x4960
xorl %eax, %eax
movl %eax, %edi
callq 0x3210
movl %eax, %edi
callq 0x3230
movl $0x2, -0x8c(%rbp)
leaq -0xa8(%rbp), %rdi
callq 0x5940
movl $0x0, -0xac(%rbp)
movl -0xac(%rbp), %eax
cmpl -0x8c(%rbp), %eax
jge 0x4798
leaq -0xc0(%rbp), %rdi
leaq -0x48(%rbp), %rsi
movl $0x2, %edx
callq 0x109c0
jmp 0x46d6
leaq -0xc0(%rbp), %rdi
callq 0x49a0
movq %rax, %rsi
leaq -0xa8(%rbp), %rdi
callq 0x5960
jmp 0x46f3
leaq -0xd0(%rbp), %rdi
movq %rdi, -0x100(%rbp)
leaq -0xc0(%rbp), %rsi
callq 0x59d0
movq -0x100(%rbp), %rdi
callq 0x3660
jmp 0x471b
leaq -0xd0(%rbp), %rdi
callq 0x4980
leaq -0xc0(%rbp), %rdi
callq 0x4980
movl -0xac(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xac(%rbp)
jmp 0x46ad
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
jmp 0x4954
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
jmp 0x4787
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
leaq -0xd0(%rbp), %rdi
callq 0x4980
leaq -0xc0(%rbp), %rdi
callq 0x4980
jmp 0x4954
leaq -0x48(%rbp), %rdi
xorl %esi, %esi
movl $0x1, %edx
callq 0x106d0
jmp 0x47aa
movl $0x0, -0xd4(%rbp)
movl -0xd4(%rbp), %eax
movl %eax, -0x104(%rbp)
leaq -0xa8(%rbp), %rdi
callq 0x5a00
movq %rax, %rcx
movl -0x104(%rbp), %eax
cmpl %ecx, %eax
jge 0x4921
movslq -0xd4(%rbp), %rsi
leaq -0xa8(%rbp), %rdi
callq 0x5a20
movq (%rax), %rdx
leaq -0xe8(%rbp), %rdi
leaq -0x48(%rbp), %rsi
xorl %ecx, %ecx
callq 0x10c20
jmp 0x4807
leaq -0xe8(%rbp), %rdi
movq %rdi, -0x118(%rbp)
callq 0x49a0
movq %rax, %rdi
addq $0x48, %rdi
callq 0x5a00
movq -0x118(%rbp), %rdi
movq %rax, -0x110(%rbp)
callq 0x49a0
movq %rax, %rdi
addq $0x60, %rdi
callq 0x5a40
movq -0x110(%rbp), %rsi
movq %rax, %rdx
leaq 0x108f4(%rip), %rdi     # 0x1514a
xorl %eax, %eax
callq 0x3050
jmp 0x485f
leaq -0xe8(%rbp), %rdi
callq 0x49a0
movq %rax, %rdi
addq $0x48, %rdi
callq 0x5a00
cmpl 0x199cb(%rip), %eax     # 0x1e248
jne 0x4881
jmp 0x48c0
leaq 0x108e5(%rip), %rdi     # 0x1516d
leaq 0x10864(%rip), %rsi     # 0x150f3
movl $0x50, %edx
leaq 0x10959(%rip), %rcx     # 0x151f4
callq 0x3180
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
leaq -0xe8(%rbp), %rdi
callq 0x4980
jmp 0x4954
leaq -0xe8(%rbp), %rdi
callq 0x49a0
movq %rax, %rdi
addq $0x60, %rdi
callq 0x5a40
cmpl 0x1996a(%rip), %eax     # 0x1e248
jne 0x48e2
jmp 0x4901
leaq 0x108b6(%rip), %rdi     # 0x1519f
leaq 0x10803(%rip), %rsi     # 0x150f3
movl $0x51, %edx
leaq 0x108f8(%rip), %rcx     # 0x151f4
callq 0x3180
leaq -0xe8(%rbp), %rdi
callq 0x4980
movl -0xd4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xd4(%rbp)
jmp 0x47b4
leaq -0x48(%rbp), %rdi
callq 0x10650
jmp 0x492c
leaq -0xa8(%rbp), %rdi
callq 0x5a60
movl $0x0, -0x88(%rbp)
leaq -0x48(%rbp), %rdi
callq 0x5570
addq $0x120, %rsp            # imm = 0x120
popq %rbp
retq
leaq -0xa8(%rbp), %rdi
callq 0x5a60
leaq -0x48(%rbp), %rdi
callq 0x5570
movq -0x80(%rbp), %rdi
callq 0x3430
nopw %cs:(%rax,%rax)
nopl (%rax)