2016-11-24 22:52:19 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <time.h>
|
|
|
|
#include "ipfs/namesys/namesys.h"
|
|
|
|
|
|
|
|
int main(int argc, char **argv)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
tlds chk[] = {
|
|
|
|
{ "foo.bar.baz.com", 1 },
|
|
|
|
{ "foo.bar.baz", 0 },
|
|
|
|
{ "foo.bar.baz.com.", 1 },
|
|
|
|
{ "com", 0 }, // yeah yeah...
|
|
|
|
{ ".", 0 }, // yeah yeah...
|
|
|
|
{ "..", 0 },
|
|
|
|
{ ".foo.com.", 0 },
|
|
|
|
{ ".foo.com", 0 },
|
|
|
|
{ "fo o.com", 0 },
|
|
|
|
{ "example.com", 1 },
|
|
|
|
{ "fjdoisajfdiosafdsa8fd8saf8dsa8fdsafdsa-fd-sa-fd-saf-dsa.org", 1 },
|
|
|
|
{ "fjdoisajfdiosafdsa8fd8saf8dsa8fdsafdsa-fd-sa-fd-saf-dsa.bit", 1 },
|
|
|
|
{ "fjdoisajfdiosafdsa8fd8saf8dsa8fdsafdsa-fd-sa-fd-saf-dsa.onion", 1 },
|
|
|
|
{ "a.b.c.d.e.f.g.h.i.j.k.l.museum", 1 },
|
|
|
|
{ "a.b.c.d.e.f.g.h.i.j.k.l", 0 },
|
|
|
|
{ NULL, 0 }
|
|
|
|
};
|
|
|
|
|
|
|
|
for (i = 0 ; chk[i].str ; i++) {
|
2016-12-05 11:55:17 +00:00
|
|
|
if (ipfs_isdomain_is_domain (chk[i].str) != chk[i].condition) {
|
2016-11-24 22:52:19 +00:00
|
|
|
printf ("Misclassification: %s should be %d\n", chk[i].str, chk[i].condition);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|