#include <stdio.h>
#include "ip_to_geo.h"

#define IP(a, b, c, d) ((a << 24) | (b << 16) | (c << 8) | d)

static void do_test(int a, int b, int c, int d)
{
    const uint8_t* cc;

    cc = ip_to_geo(IP(a,b,c,d));
    printf("IP %d.%d.%d.%d : %s\n", a, b, c, d, (cc)?(char*)get_country_code(cc):"<none>");
}

int self_test()
{
    do_test(1,5,7,3);
    do_test(1,5,255,4);
    do_test(1,6,255,4);
    do_test(2,0,0,0);
    do_test(127,0,0,1);
    do_test(1,55,3,12);
    do_test(1,57,0,0);

    return 0;
}
