int main(int argc, char * argv []) { test_poly(); test_utm(); test_ps(); test_lamaz(); test_lamcc(); test_alb(); perf_test_ps(); test_random_all(); if (nfail == 0) printf("%d tests passed!\n", nok); else printf("%d ok, %d failures.\n", nok, nfail); return nfail; }
/* section: either PSL_TYPE_PRIVATE or PSL_TYPE_ICANN */ static void test_type_any(const psl_ctx_t *psl, const char *domain, int type, int expected) { int wildcard = (*domain == '.'); int tld = !(strchr(domain + wildcard, '.')); test_ps(psl, domain, type, expected); test_ps(psl, domain, type|PSL_TYPE_NO_STAR_RULE, expected); test_ps(psl, domain, PSL_TYPE_ANY, expected); test_ps(psl, domain, PSL_TYPE_ANY|PSL_TYPE_NO_STAR_RULE, expected); if (type == PSL_TYPE_PRIVATE) { if (tld) { test_ps(psl, domain, PSL_TYPE_ICANN, 1); test_ps(psl, domain, PSL_TYPE_ICANN|PSL_TYPE_NO_STAR_RULE, 0); } else { test_ps(psl, domain, PSL_TYPE_ICANN, 0); test_ps(psl, domain, PSL_TYPE_ICANN|PSL_TYPE_NO_STAR_RULE, 0); } } else if (type == PSL_TYPE_ICANN) { if (tld) { test_ps(psl, domain, PSL_TYPE_PRIVATE, 1); test_ps(psl, domain, PSL_TYPE_PRIVATE|PSL_TYPE_NO_STAR_RULE, 0); } else { test_ps(psl, domain, PSL_TYPE_PRIVATE, 0); test_ps(psl, domain, PSL_TYPE_PRIVATE|PSL_TYPE_NO_STAR_RULE, 0); } } }