// File: /workspace/github_c_makefile_star2_O1/sgsfak[P]c-ocgeo/tests/tests.c
// Function: main
int main(int argc, char* argv[])
{

    ocgeo_dms_t dd;

    ocgeo_params_t params = ocgeo_default_params();
    ocgeo_response_t response;
    params.no_record = true;
    params.no_annotations = true;
    const char* query = "Syena, Aswan Governorate, Egypt";
    ocgeo_forward(query, "4372eff77b8343cebfc843eb4da4ddc4", &params, &response);
    TEST("Testing 402 response", response.status.code == OCGEO_CODE_QUOTA_ERROR);
    ocgeo_response_cleanup(&response);
    ocgeo_forward(query, "2e10e5e828262eb243ec0b54681d699a", &params, &response);
    TEST("Testing 403 response", response.status.code == OCGEO_CODE_FORBIDDEN);
    ocgeo_response_cleanup(&response);
    ocgeo_forward(query, "d6d0f0065f4348a4bdfe4587ba02714b", &params, &response);
    TEST("Testing 429 response", response.status.code == OCGEO_CODE_MANY_REQUESTS);
    ocgeo_response_cleanup(&response);

    params.no_annotations = false;
    ocgeo_forward(query, "6d0e711d72d74daeb2b0bfd2a5cdfdba", &params, &response);
    TEST("Testing 200 response", response.status.code == OCGEO_CODE_OK);
    TEST("Testing getting results", response.total_results > 0 && response.results != NULL);
    ocgeo_result_t* result = response.results;
    TEST("Testing currency annotation", result->currency != NULL &&
        strcmp(result->currency->iso_code, "EUR")==0 &&
        strcmp(result->currency->name, "Euro")==0 &&
        strcmp(result->currency->thousands_separator, ".")==0 &&
        strcmp(result->currency->decimal_mark, ",")==0);
    TEST("Testing road info annotation", result->roadinfo != NULL &&
        strcmp(result->roadinfo->speed_in, "km/h")==0 &&
        strcmp(result->roadinfo->drive_on, "right")==0);
    TEST("Testing 'what3words' annotation", result->what3words != NULL);
    TEST("Testing 'geohash' annotation", result->geohash != NULL);
    
    bool ok;
    const char* lat = ocgeo_response_get_str(result, "annotations.DMS.lat", &ok);
    TEST("Testing adv API, getting DMS lat", ok);
    int callingCode = ocgeo_response_get_int(result, "annotations.callingcode", &ok);
    TEST("Testing adv API, getting calling code", ok && callingCode == 49);
    printf("\t\tDMS lat = \"%s\", calling code=%d\n", lat, callingCode);

    TEST("Testing adv API, getting bounds", 
        d_eq_7(ocgeo_response_get_dbl(result, "bounds.northeast.lat", &ok), 51.9528202));
    TEST("Testing adv API, getting nonexistent string field", 
        ocgeo_response_get_str(result, "annotations.NON-EXISTENT", &ok) == NULL && !ok);

    ocgeo_response_cleanup(&response);


    TEST_DEC_TO_DEG(-10.1245839, -10, 7, 28.5);
    TEST_DEC_TO_DEG(-89.5006900, -89, 30, 2.48);
    TEST_DEC_TO_DEG(32.8247971, 32, 49, 29.27);
    TEST_DEC_TO_DEG(21.8545795, 21, 51, 16.49);

    TEST_DEG_TO_DEC(-10.1245839);
    TEST_DEG_TO_DEC(-89.5006900);

    printf("\n%d failed, %d pass\n", count_fail, count_pass);
    return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xb8, %rsp
leaq 0x48(%rsp), %r12
movq %r12, %rdi
callq 0x1900
movb $0x1, %al
movb %al, 0x52(%r12)
movb %al, 0x50(%r12)
leaq 0x5d0f(%rip), %rbx      # 0x703c
leaq 0x5d28(%rip), %rsi      # 0x705c
leaq 0x10(%rsp), %r14
movq %rbx, %rdi
movq %r12, %rdx
movq %r14, %rcx
callq 0x1935
cmpl $0x192, (%r14)          # imm = 0x192
leaq 0x5d28(%rip), %r15      # 0x707d
leaq 0x5d4a(%rip), %rdi      # 0x70a6
cmoveq %r15, %rdi
leaq 0x9dc5(%rip), %rcx      # 0xb12c
leaq 0x9dc2(%rip), %rbp      # 0xb130
movq %rbp, %r13
cmoveq %rcx, %r13
leaq 0x5d15(%rip), %rsi      # 0x7091
xorl %eax, %eax
callq 0x1030
incl (%r13)
movq %r14, %rdi
callq 0x1d7e
leaq 0x5d24(%rip), %rsi      # 0x70ba
movq %rbx, %rdi
movq %r12, %rdx
movq %r14, %rcx
callq 0x1935
cmpl $0x193, (%r14)          # imm = 0x193
leaq 0x5cf4(%rip), %r12      # 0x70a6
movq %r12, %rdi
cmoveq %r15, %rdi
movq %rbp, %r13
leaq 0x9d69(%rip), %rax      # 0xb12c
cmoveq %rax, %r13
leaq 0x5d0d(%rip), %rsi      # 0x70db
xorl %eax, %eax
callq 0x1030
incl (%r13)
movq %r14, %rdi
callq 0x1d7e
leaq 0x5d08(%rip), %rsi      # 0x70f0
movq %rbx, %rdi
leaq 0x48(%rsp), %rdx
movq %r14, %rcx
callq 0x1935
cmpl $0x1ad, (%r14)          # imm = 0x1AD
movq %r12, %rdi
cmoveq %r15, %rdi
movq %rbp, %r13
movq %rbp, %rbx
leaq 0x9d19(%rip), %rbp      # 0xb12c
cmoveq %rbp, %r13
leaq 0x5cf3(%rip), %rsi      # 0x7111
xorl %eax, %eax
callq 0x1030
incl (%r13)
movq %rbx, %r13
movq %r14, %rdi
callq 0x1d7e
leaq 0x48(%rsp), %rdx
movb $0x0, 0x50(%rdx)
leaq 0x5ce2(%rip), %rsi      # 0x7126
leaq 0x5bf1(%rip), %rdi      # 0x703c
movq %r12, %rbx
movq %r14, %rcx
callq 0x1935
cmpl $0xc8, (%r14)
movq %r12, %rdi
cmoveq %r15, %rdi
movq %r13, %r12
cmoveq %rbp, %r12
leaq 0x5cd5(%rip), %rsi      # 0x7147
xorl %eax, %eax
callq 0x1030
incl (%r12)
cmpl $0x0, 0x24(%r14)
setg %al
cmpq $0x0, 0x28(%r14)
setne %cl
testb %cl, %al
movq %rbx, %rdi
cmovneq %r15, %rdi
movq %r13, %r12
cmovneq %rbp, %r12
leaq 0x5cb8(%rip), %rsi      # 0x715c
xorl %eax, %eax
callq 0x1030
incl (%r12)
movq 0x28(%r14), %r14
movq 0xc8(%r14), %r12
testq %r12, %r12
je 0x1512
movq 0x8(%r12), %rdi
leaq 0x5ca9(%rip), %rsi      # 0x7174
callq 0x11a0
testl %eax, %eax
jne 0x1512
movq (%r12), %rdi
leaq 0x5c99(%rip), %rsi      # 0x7178
callq 0x11a0
testl %eax, %eax
jne 0x1512
movq 0x20(%r12), %rdi
leaq 0x5c89(%rip), %rsi      # 0x717d
callq 0x11a0
testl %eax, %eax
jne 0x1512
movq 0x18(%r12), %rdi
leaq 0x5c76(%rip), %rsi      # 0x717f
callq 0x11a0
testl %eax, %eax
je 0x1520
leaq 0x9c17(%rip), %rbp      # 0xb130
leaq 0x5b86(%rip), %r15      # 0x70a6
leaq 0x5c5a(%rip), %rsi      # 0x7181
movq %r15, %rdi
xorl %eax, %eax
callq 0x1030
incl (%rbp)
movq 0xc0(%r14), %r15
testq %r15, %r15
je 0x156b
movq 0x8(%r15), %rdi
leaq 0x5c52(%rip), %rsi      # 0x719d
callq 0x11a0
testl %eax, %eax
jne 0x156b
movq (%r15), %rdi
leaq 0x5c44(%rip), %rsi      # 0x71a2
callq 0x11a0
testl %eax, %eax
je 0x18ed
leaq 0x9bbe(%rip), %r15      # 0xb130
leaq 0x5b2d(%rip), %rdi      # 0x70a6
leaq 0x5c28(%rip), %rsi      # 0x71a8
xorl %eax, %eax
callq 0x1030
incl (%r15)
cmpq $0x0, 0xd8(%r14)
leaq 0x5ae4(%rip), %rbp      # 0x707d
movq %rbp, %rdi
cmoveq %rbx, %rdi
leaq 0x9b85(%rip), %r12      # 0xb12c
movq %r12, %r15
cmoveq %r13, %r15
leaq 0x5c10(%rip), %rsi      # 0x71c5
xorl %eax, %eax
callq 0x1030
incl (%r15)
cmpq $0x0, 0xd0(%r14)
movq %rbp, %rdi
cmoveq %rbx, %rdi
movq %r12, %r15
cmoveq %r13, %r15
leaq 0x5c09(%rip), %rsi      # 0x71e5
xorl %eax, %eax
callq 0x1030
incl (%r15)
leaq 0x5c15(%rip), %rsi      # 0x7202
leaq 0x7(%rsp), %r15
movq %r14, %rdi
movq %r15, %rdx
callq 0x1e1d
cmpb $0x0, (%r15)
cmoveq %rbx, %rbp
movq %rax, 0x8(%rsp)
movq %r13, %r15
movq %r12, %r13
cmoveq %r15, %r13
leaq 0x5bfb(%rip), %rsi      # 0x7216
movq %rbp, %rdi
xorl %eax, %eax
callq 0x1030
incl (%r13)
leaq 0x5c07(%rip), %rsi      # 0x7237
movq %r14, %rdi
leaq 0x7(%rsp), %r13
movq %r13, %rdx
callq 0x1f8d
movl %eax, %ebp
cmpl $0x31, %eax
sete %al
testb %al, (%r13)
leaq 0x5a2a(%rip), %rdi      # 0x707d
cmoveq %rbx, %rdi
movq %r12, %r13
cmoveq %r15, %r13
leaq 0x5bea(%rip), %rsi      # 0x724f
xorl %eax, %eax
callq 0x1030
incl (%r13)
movq %r15, %r13
leaq 0x5a03(%rip), %r15      # 0x707d
leaq 0x5bf4(%rip), %rdi      # 0x7275
movq 0x8(%rsp), %rsi
movl %ebp, %edx
movq %r12, %rbp
xorl %eax, %eax
callq 0x1030
leaq 0x5bff(%rip), %rsi      # 0x7298
movq %r14, %rdi
leaq 0x7(%rsp), %rdx
callq 0x1fd6
mulsd 0x595a(%rip), %xmm0     # 0x7008
cvtsd2ss %xmm0, %xmm0
callq 0x1190
movq %rax, %r12
movss 0x594e(%rip), %xmm0     # 0x7010
callq 0x1190
cmpq %rax, %r12
movq %rbx, %rdi
cmoveq %r15, %rdi
movq %r13, %r12
cmoveq %rbp, %r12
leaq 0x5bce(%rip), %rsi      # 0x72ad
xorl %eax, %eax
callq 0x1030
incl (%r12)
leaq 0x5bdc(%rip), %rsi      # 0x72cd
movq %r14, %rdi
leaq 0x7(%rsp), %rdx
callq 0x1e1d
testq %rax, %rax
jne 0x1718
cmpb $0x1, 0x7(%rsp)
leaq 0x596e(%rip), %rdi      # 0x707d
leaq 0x9a16(%rip), %r14      # 0xb12c
jne 0x171e
movq %rbx, %rdi
movq %r13, %r14
leaq 0x5bc1(%rip), %rsi      # 0x72e6
xorl %eax, %eax
callq 0x1030
incl (%r14)
leaq 0x10(%rsp), %rdi
callq 0x1d7e
movss 0x58d3(%rip), %xmm0     # 0x7014
callq 0x1190
movq %rax, %r14
movss 0x58c7(%rip), %xmm0     # 0x7018
callq 0x1190
cmpq %rax, %r14
movq %rbx, %rdi
leaq 0x591a(%rip), %r15      # 0x707d
cmoveq %r15, %rdi
movq %r13, %r14
leaq 0x99bb(%rip), %r12      # 0xb12c
cmoveq %r12, %r14
leaq 0x5b9c(%rip), %rsi      # 0x7318
xorl %eax, %eax
callq 0x1030
incl (%r14)
movss 0x588e(%rip), %xmm0     # 0x701c
callq 0x1190
movq %rax, %r14
movss 0x5882(%rip), %xmm0     # 0x7020
callq 0x1190
cmpq %rax, %r14
movq %rbx, %rdi
cmoveq %r15, %rdi
movq %r13, %r14
cmoveq %r12, %r14
leaq 0x5b98(%rip), %rsi      # 0x7353
xorl %eax, %eax
callq 0x1030
incl (%r14)
movss 0x5857(%rip), %xmm0     # 0x7024
callq 0x1190
movq %rax, %r14
movss 0x584b(%rip), %xmm0     # 0x7028
callq 0x1190
cmpq %rax, %r14
movq %rbx, %rdi
cmoveq %r15, %rdi
movq %r13, %r14
cmoveq %r12, %r14
leaq 0x5b95(%rip), %rsi      # 0x738f
xorl %eax, %eax
callq 0x1030
incl (%r14)
movss 0x5820(%rip), %xmm0     # 0x702c
callq 0x1190
movq %rax, %r14
movss 0x5814(%rip), %xmm0     # 0x7030
callq 0x1190
cmpq %rax, %r14
movq %rbx, %rdi
cmoveq %r15, %rdi
movq %r13, %r14
cmoveq %r12, %r14
leaq 0x5b91(%rip), %rsi      # 0x73ca
xorl %eax, %eax
callq 0x1030
incl (%r14)
movss 0x57e9(%rip), %xmm0     # 0x7034
callq 0x1190
movq %rax, %r14
movss 0x57d9(%rip), %xmm0     # 0x7034
callq 0x1190
cmpq %rax, %r14
movq %rbx, %rdi
cmoveq %r15, %rdi
movq %r13, %r14
cmoveq %r12, %r14
leaq 0x5b8d(%rip), %rsi      # 0x7405
xorl %eax, %eax
callq 0x1030
incl (%r14)
movss 0x57ae(%rip), %xmm0     # 0x7038
callq 0x1190
movq %rax, %r14
movss 0x579e(%rip), %xmm0     # 0x7038
callq 0x1190
cmpq %rax, %r14
cmoveq %r15, %rbx
cmoveq %r12, %r13
leaq 0x5b7c(%rip), %rsi      # 0x742d
movq %rbx, %rdi
xorl %eax, %eax
callq 0x1030
incl (%r13)
movl 0x986b(%rip), %esi      # 0xb130
movl 0x9861(%rip), %edx      # 0xb12c
leaq 0x5b83(%rip), %rdi      # 0x7455
xorl %eax, %eax
callq 0x1030
xorl %eax, %eax
addq $0xb8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x9838(%rip), %r15      # 0xb12c
leaq 0x5782(%rip), %rdi      # 0x707d
jmp 0x1579