// File: /workspace/github_c_makefile_star2_O2/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 0x1ab0
movb $0x1, %al
movb %al, 0x52(%r12)
movb %al, 0x50(%r12)
leaq 0x4d53(%rip), %rbx      # 0x6080
leaq 0x4d6c(%rip), %rsi      # 0x60a0
leaq 0x10(%rsp), %r14
movq %rbx, %rdi
movq %r12, %rdx
movq %r14, %rcx
callq 0x1ae5
cmpl $0x192, (%r14)          # imm = 0x192
leaq 0x4d6c(%rip), %r15      # 0x60c1
leaq 0x4d8e(%rip), %rdi      # 0x60ea
cmoveq %r15, %rdi
leaq 0x8dc5(%rip), %rbp      # 0xa12c
leaq 0x8dc2(%rip), %r13      # 0xa130
cmoveq %rbp, %r13
leaq 0x4d5c(%rip), %rsi      # 0x60d5
xorl %eax, %eax
callq 0x1030
incl (%r13)
movq %r14, %rdi
callq 0x26b6
leaq 0x4d6b(%rip), %rsi      # 0x60fe
movq %rbx, %rdi
movq %r12, %rdx
movq %r14, %rcx
callq 0x1ae5
cmpl $0x193, (%r14)          # imm = 0x193
leaq 0x4d3b(%rip), %r12      # 0x60ea
movq %r12, %rdi
cmoveq %r15, %rdi
leaq 0x8d73(%rip), %r13      # 0xa130
cmoveq %rbp, %r13
leaq 0x4d57(%rip), %rsi      # 0x611f
xorl %eax, %eax
callq 0x1030
incl (%r13)
movq %r14, %rdi
callq 0x26b6
leaq 0x4d52(%rip), %rsi      # 0x6134
movq %rbx, %rdi
leaq 0x48(%rsp), %rdx
movq %r14, %rcx
callq 0x1ae5
cmpl $0x1ad, (%r14)          # imm = 0x1AD
movq %r12, %rdi
cmoveq %r15, %rdi
leaq 0x8d29(%rip), %rbx      # 0xa130
movq %rbx, %r13
cmoveq %rbp, %r13
leaq 0x4d40(%rip), %rsi      # 0x6155
xorl %eax, %eax
callq 0x1030
incl (%r13)
movq %rbx, %r13
movq %r14, %rdi
callq 0x26b6
leaq 0x48(%rsp), %rdx
movb $0x0, 0x50(%rdx)
leaq 0x4d2f(%rip), %rsi      # 0x616a
leaq 0x4c3e(%rip), %rdi      # 0x6080
movq %r14, %rcx
callq 0x1ae5
cmpl $0xc8, (%r14)
movq %r12, %rbx
movq %r12, %rdi
cmoveq %r15, %rdi
movq %r13, %r12
cmoveq %rbp, %r12
leaq 0x4d22(%rip), %rsi      # 0x618b
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 0x4d05(%rip), %rsi      # 0x61a0
xorl %eax, %eax
callq 0x1030
incl (%r12)
movq 0x28(%r14), %r14
movq 0xc8(%r14), %r12
testq %r12, %r12
je 0x14ff
movq 0x8(%r12), %rdi
leaq 0x4cf6(%rip), %rsi      # 0x61b8
callq 0x11a0
testl %eax, %eax
jne 0x14ff
movq (%r12), %rdi
leaq 0x4ce6(%rip), %rsi      # 0x61bc
callq 0x11a0
testl %eax, %eax
jne 0x14ff
movq 0x20(%r12), %rax
cmpb $0x2e, (%rax)
jne 0x14ff
cmpb $0x0, 0x1(%rax)
jne 0x14ff
movq 0x18(%r12), %rax
cmpb $0x2c, (%rax)
jne 0x14ff
cmpb $0x0, 0x1(%rax)
je 0x150d
leaq 0x8c2a(%rip), %rbp      # 0xa130
leaq 0x4bdd(%rip), %r15      # 0x60ea
leaq 0x4cad(%rip), %rsi      # 0x61c1
movq %r15, %rdi
xorl %eax, %eax
callq 0x1030
incl (%rbp)
movq 0xc0(%r14), %r15
testq %r15, %r15
je 0x1558
movq 0x8(%r15), %rdi
leaq 0x4ca5(%rip), %rsi      # 0x61dd
callq 0x11a0
testl %eax, %eax
jne 0x1558
movq (%r15), %rdi
leaq 0x4c97(%rip), %rsi      # 0x61e2
callq 0x11a0
testl %eax, %eax
je 0x19b7
leaq 0x8bd1(%rip), %r15      # 0xa130
leaq 0x4b84(%rip), %rdi      # 0x60ea
leaq 0x4c7b(%rip), %rsi      # 0x61e8
xorl %eax, %eax
callq 0x1030
incl (%r15)
cmpq $0x0, 0xd8(%r14)
leaq 0x4b3b(%rip), %rax      # 0x60c1
movq %rax, %rdi
movq %rax, %r12
movq %rbx, %rbp
cmoveq %rbx, %rdi
leaq 0x8b92(%rip), %rax      # 0xa12c
movq %rax, %r15
movq %rax, %rbx
cmoveq %r13, %r15
leaq 0x4c5a(%rip), %rsi      # 0x6205
xorl %eax, %eax
callq 0x1030
incl (%r15)
cmpq $0x0, 0xd0(%r14)
movq %r12, %rdi
cmoveq %rbp, %rdi
movq %rbx, %r15
cmoveq %r13, %r15
leaq 0x4c53(%rip), %rsi      # 0x6225
xorl %eax, %eax
callq 0x1030
incl (%r15)
leaq 0x4c5f(%rip), %rsi      # 0x6242
leaq 0x7(%rsp), %r15
movq %r14, %rdi
movq %r15, %rdx
callq 0x274c
cmpb $0x0, (%r15)
movq %r12, %rdi
cmoveq %rbp, %rdi
movq %rax, %r12
movq %r13, %rbx
leaq 0x8b21(%rip), %r13      # 0xa12c
cmoveq %rbx, %r13
leaq 0x4c40(%rip), %rsi      # 0x6256
xorl %eax, %eax
callq 0x1030
incl (%r13)
leaq 0x4c4f(%rip), %rsi      # 0x6277
movq %r14, %rdi
movq %r15, %rdx
callq 0x289b
movl %eax, %ebp
cmpl $0x31, %eax
sete %al
testb %al, (%r15)
leaq 0x4a7c(%rip), %rdi      # 0x60c1
leaq 0x4a9e(%rip), %rax      # 0x60ea
cmoveq %rax, %rdi
leaq 0x8ad5(%rip), %r13      # 0xa12c
cmoveq %rbx, %r13
leaq 0x4c2d(%rip), %rsi      # 0x628f
xorl %eax, %eax
callq 0x1030
incl (%r13)
leaq 0x4a76(%rip), %r13      # 0x60ea
leaq 0x4c3a(%rip), %rdi      # 0x62b5
movq %r12, %rsi
movl %ebp, %edx
leaq 0x4a3a(%rip), %r12      # 0x60c1
xorl %eax, %eax
callq 0x1030
leaq 0x4c43(%rip), %rsi      # 0x62d8
movq %r14, %rdi
movq %r15, %rdx
callq 0x28e4
movsd 0x4960(%rip), %xmm1     # 0x6008
movl $0xf4240, %edi          # imm = 0xF4240
callq 0x19ca
testb %al, %al
movq %r12, %rdi
cmoveq %r13, %rdi
leaq 0x8a6a(%rip), %r12      # 0xa12c
movq %r12, %rbp
cmoveq %rbx, %r12
leaq 0x4c1d(%rip), %rsi      # 0x62ed
xorl %eax, %eax
callq 0x1030
incl (%r12)
leaq 0x4c2b(%rip), %rsi      # 0x630d
movq %r14, %rdi
movq %r15, %rdx
callq 0x274c
testq %rax, %rax
jne 0x16fd
cmpb $0x1, 0x7(%rsp)
jne 0x19a4
leaq 0x8a2c(%rip), %r14      # 0xa130
leaq 0x49df(%rip), %rdi      # 0x60ea
leaq 0x4c14(%rip), %rsi      # 0x6326
xorl %eax, %eax
callq 0x1030
incl (%r14)
leaq 0x10(%rsp), %rdi
callq 0x26b6
movsd 0x48e2(%rip), %xmm0     # 0x6010
callq 0x1a0e
movq %rax, %r14
movss %xmm0, 0xc(%rsp)
movabsq $0x7fffffff6, %rax      # imm = 0x7FFFFFFF6
cmpq %rax, %r14
jne 0x1773
cvtss2sd 0xc(%rsp), %xmm0
movsd 0x48bf(%rip), %xmm1     # 0x6018
pushq $0x64
popq %rdi
callq 0x19ca
testb %al, %al
je 0x1773
leaq 0x89c0(%rip), %rbx      # 0xa12c
leaq 0x494e(%rip), %r13      # 0x60c1
leaq 0x4bde(%rip), %rsi      # 0x6358
movq %r13, %rdi
xorl %eax, %eax
callq 0x1030
incl (%rbx)
movsd 0x4892(%rip), %xmm0     # 0x6020
callq 0x1a0e
movq %rax, %rbx
movss %xmm0, 0x8(%rsp)
movabsq $0x1effffffa7, %rax     # imm = 0x1EFFFFFFA7
cmpq %rax, %rbx
jne 0x17d5
cvtss2sd 0x8(%rsp), %xmm0
movsd 0x486f(%rip), %xmm1     # 0x6028
pushq $0x64
popq %rdi
callq 0x19ca
testb %al, %al
je 0x17d5
leaq 0x8960(%rip), %r15      # 0xa12c
leaq 0x48ee(%rip), %rdi      # 0x60c1
jmp 0x17e3
leaq 0x8954(%rip), %r15      # 0xa130
leaq 0x4907(%rip), %rdi      # 0x60ea
leaq 0x4ba9(%rip), %rsi      # 0x6393
xorl %eax, %eax
callq 0x1030
incl (%r15)
movsd 0x4834(%rip), %xmm0     # 0x6030
callq 0x1a0e
movabsq $0x3100000020, %rcx     # imm = 0x3100000020
cmpq %rcx, %rax
jne 0x1838
cvtss2sd %xmm0, %xmm0
movsd 0x481c(%rip), %xmm1     # 0x6038
pushq $0x64
popq %rdi
callq 0x19ca
testb %al, %al
je 0x1838
leaq 0x88fd(%rip), %r15      # 0xa12c
leaq 0x488b(%rip), %rdi      # 0x60c1
jmp 0x1846
leaq 0x88f1(%rip), %r15      # 0xa130
leaq 0x48a4(%rip), %rdi      # 0x60ea
leaq 0x4b82(%rip), %rsi      # 0x63cf
xorl %eax, %eax
callq 0x1030
incl (%r15)
movsd 0x47e1(%rip), %xmm0     # 0x6040
callq 0x1a0e
movabsq $0x3300000015, %rcx     # imm = 0x3300000015
cmpq %rcx, %rax
jne 0x1895
cvtss2sd %xmm0, %xmm0
movsd 0x47c9(%rip), %xmm1     # 0x6048
pushq $0x64
popq %rdi
callq 0x19ca
leaq 0x4833(%rip), %rdi      # 0x60c1
movq %rbp, %r15
testb %al, %al
jne 0x18a3
leaq 0x8894(%rip), %r15      # 0xa130
leaq 0x4847(%rip), %rdi      # 0x60ea
leaq 0x4b60(%rip), %rsi      # 0x640a
xorl %eax, %eax
callq 0x1030
incl (%r15)
movq %r14, %rdi
movss 0xc(%rsp), %xmm0
callq 0x1a6c
movaps %xmm0, %xmm1
movsd 0x4743(%rip), %xmm0     # 0x6010
movl $0x186a0, %edi          # imm = 0x186A0
callq 0x19ca
leaq 0x480c(%rip), %rdi      # 0x60ea
testb %al, %al
leaq 0x47da(%rip), %rax      # 0x60c1
cmovneq %rax, %rdi
leaq 0x883e(%rip), %r14      # 0xa130
cmovneq %rbp, %r14
leaq 0x4b48(%rip), %rsi      # 0x6445
xorl %eax, %eax
callq 0x1030
incl (%r14)
movq %rbx, %rdi
movss 0x8(%rsp), %xmm0
callq 0x1a6c
movaps %xmm0, %xmm1
movsd 0x4700(%rip), %xmm0     # 0x6020
movl $0x186a0, %edi          # imm = 0x186A0
callq 0x19ca
testb %al, %al
je 0x1959
leaq 0x478c(%rip), %rdi      # 0x60c1
leaq 0x4b31(%rip), %rsi      # 0x646d
xorl %eax, %eax
callq 0x1030
movl 0x87e3(%rip), %edx      # 0xa12c
incl %edx
movl %edx, 0x87db(%rip)      # 0xa12c
movl 0x87d9(%rip), %esi      # 0xa130
jmp 0x1982
leaq 0x478a(%rip), %rdi      # 0x60ea
leaq 0x4b06(%rip), %rsi      # 0x646d
xorl %eax, %eax
callq 0x1030
movl 0x87bc(%rip), %esi      # 0xa130
incl %esi
movl %esi, 0x87b4(%rip)      # 0xa130
movl 0x87aa(%rip), %edx      # 0xa12c
leaq 0x4b0c(%rip), %rdi      # 0x6495
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 0x8781(%rip), %r14      # 0xa12c
leaq 0x470f(%rip), %rdi      # 0x60c1
jmp 0x170b
leaq 0x876e(%rip), %r15      # 0xa12c
leaq 0x46fc(%rip), %rdi      # 0x60c1
jmp 0x1566