// File: /workspace/github_c_makefile_star2_O2/mruby-zest[P]osc-bridge/test/mock-test.c
// Function: main
int main()
{
    bool verbose = false;
    test_plan(21);

    //Apply Debug Hooks
    printf("#Setting up hooks...\n");
    osc_request_hook = osc_request_hook_fn;
    osc_socket_hook  = osc_socket_hook_fn;

    //Define that there is a bridge on localhost:1337
    bridge_t *bridge = br_create("osc.udp://localhost:1337");
    assert_non_null(bridge, "A Bridge is allocated", __LINE__);

    //Get the bridge to obtain the schema
    printf("#Creating Schema For Remote...\n");
    schema_t schema = br_get_schema(bridge, "/schema");
    assert_true(1000 <  schema.elements,
            "Schema has around the right number of elements", __LINE__);

    assert_int_eq(255, v1, "Verify pre-callback #1 data", __LINE__);
    assert_int_eq(255, v2, "Verify pre-callback #2 data", __LINE__);
    assert_false(v3, "Verify pre-callback #3 data", __LINE__);

    test_part_level(schema, bridge);
    test_options(schema, bridge);
    assert_int_eq(32, v1, "Callback #1 was applied", __LINE__);
    assert_int_eq(32, v2, "Callback #2 was applied", __LINE__);
    assert_true(v3, "Callback #3 was applied", __LINE__);

    br_default(bridge, schema, "/part0/Pvolume");

    assert_int_eq(96, v1, "Default #1 was applied", __LINE__);
    assert_int_eq(96, v2, "Default #2 was applied", __LINE__);

    printf("#bridge receive...\n");
    assert_int_eq(2, bridge->cache_len,
            "Verify number of cache fields", __LINE__);
    assert_int_eq(3, bridge->callback_len,
            "Verify number of callbacks", __LINE__);
    br_recv(bridge, 0);

    if(verbose) {
        for(int i=0; i<bridge->callback_len; ++i)
            printf("callback[%d][%s][%p]\n", i, bridge->callback[i].path,
                    bridge->callback[i].data);
        for(int i=0; i<bridge->cache_len; ++i)
            printf("cache[%d][%s][%d]\n", i, bridge->cache[i].path,
                    bridge->cache[i].pending);
    }

    assert_int_eq(0, br_pending(bridge),
            "No Cache Line is Pending", __LINE__);

    test_vector_functionality(bridge);

    //cleanup
    br_destroy(bridge);
    br_destroy_schema(schema);


    return test_summary();
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x38, %rsp
pushq $0x15
popq %rdi
callq 0x78de
leaq 0x2187(%rip), %rdi      # 0xa1c2
callq 0x2080
leaq -0x700(%rip), %rax      # 0x7947
leaq 0x5162(%rip), %rcx      # 0xd1b0
movq %rax, (%rcx)
leaq -0x719(%rip), %rax      # 0x793f
leaq 0x5149(%rip), %rcx      # 0xd1a8
movq %rax, (%rcx)
leaq 0x1f41(%rip), %rdi      # 0x9faa
callq 0x2747
movq %rax, %rbx
leaq 0x1f4b(%rip), %rsi      # 0x9fc3
movq %rax, %rdi
movl $0xb7, %edx
callq 0x74db
leaq 0x214b(%rip), %rdi      # 0xa1d7
callq 0x2080
leaq 0x1d3e(%rip), %rdx      # 0x9dd6
leaq -0x30(%rbp), %r14
movq %r14, %rdi
movq %rbx, %rsi
callq 0x2ad5
xorl %edi, %edi
cmpl $0x3e9, 0x10(%r14)      # imm = 0x3E9
setge %dil
leaq 0x1f1d(%rip), %rsi      # 0x9fd9
movl $0xbd, %edx
callq 0x73d8
movl 0x50c4(%rip), %esi      # 0xd190
leaq 0x1f35(%rip), %rdx      # 0xa008
movl $0xff, %edi
movl $0xbf, %ecx
callq 0x72e4
movl 0x50ac(%rip), %esi      # 0xd194
leaq 0x1f35(%rip), %rdx      # 0xa024
movl $0xff, %edi
movl $0xc0, %ecx
callq 0x72e4
movzbl 0x56d3(%rip), %edi      # 0xd7d8
leaq 0x1f34(%rip), %rsi      # 0xa040
movl $0xc1, %edx
callq 0x743a
movq 0x10(%r14), %rax
movq %rax, 0x10(%rsp)
movups (%r14), %xmm0
movups %xmm0, (%rsp)
movq %rbx, %rdi
callq 0x7f4a
movq 0x10(%r14), %rax
movq %rax, 0x10(%rsp)
movups (%r14), %xmm0
movups %xmm0, (%rsp)
callq 0x7e83
movl 0x5045(%rip), %esi      # 0xd190
leaq 0x1f0a(%rip), %rdx      # 0xa05c
pushq $0x20
popq %r15
movl %r15d, %edi
movl $0xc5, %ecx
callq 0x72e4
movl 0x502b(%rip), %esi      # 0xd194
leaq 0x1f04(%rip), %rdx      # 0xa074
movl %r15d, %edi
movl $0xc6, %ecx
callq 0x72e4
movzbl 0x5654(%rip), %edi      # 0xd7d8
leaq 0x1f01(%rip), %rsi      # 0xa08c
movl $0xc7, %edx
callq 0x73d8
movq 0x10(%r14), %rax
movq %rax, 0x10(%rsp)
movups (%r14), %xmm0
movups %xmm0, (%rsp)
leaq 0x1c31(%rip), %rsi      # 0x9dde
movq %rbx, %rdi
callq 0x2c17
movl 0x4fd5(%rip), %esi      # 0xd190
leaq 0x1ee2(%rip), %rdx      # 0xa0a4
pushq $0x60
popq %r15
movl %r15d, %edi
movl $0xcb, %ecx
callq 0x72e4
movl 0x4fbb(%rip), %esi      # 0xd194
leaq 0x1edb(%rip), %rdx      # 0xa0bb
movl %r15d, %edi
movl $0xcc, %ecx
callq 0x72e4
leaq 0x2002(%rip), %rdi      # 0xa1f6
callq 0x2080
movl 0x120(%rbx), %esi
leaq 0x1ecc(%rip), %rdx      # 0xa0d2
pushq $0x2
popq %rdi
movl $0xd0, %ecx
callq 0x72e4
movl 0x128(%rbx), %esi
leaq 0x1ed0(%rip), %rdx      # 0xa0f0
pushq $0x3
popq %rdi
movl $0xd2, %ecx
callq 0x72e4
movq %rbx, %rdi
xorl %esi, %esi
callq 0x244c
movq %rbx, %rdi
callq 0x3b0a
leaq 0x1ec5(%rip), %rdx      # 0xa10b
xorl %edi, %edi
movl %eax, %esi
movl $0xdf, %ecx
callq 0x72e4
movq %rbx, %rdi
callq 0x7f7a
movq %rbx, %rdi
callq 0x28da
movq 0x10(%r14), %rax
movq %rax, 0x10(%rsp)
movups (%r14), %xmm0
movups %xmm0, (%rsp)
callq 0x5d38
callq 0x78f3
addq $0x38, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq