File: test.php

package info (click to toggle)
php-net-publicsuffix 0.2-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, buster, sid, stretch
  • size: 76 kB
  • ctags: 50
  • sloc: php: 153; makefile: 4
file content (46 lines) | stat: -rwxr-xr-x 959 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/usr/bin/php
<?php

require_once('Net/PublicSuffix.php');

global $errorcount;
global $testcount;

function p($x) {
  if (is_null($x))
    return 'NULL';
  else
    return $x;
}

function checkPublicSuffix($d, $v) {
  global $errorcount;
  global $testcount;
  $testcount += 1;
  try {
    $n = Net_PublicSuffix::registered_domain($d);
    if ($n !== $v) {
      $errorcount++;
      printf("test %d    error: domain: %s\texpected: %s\tgot: %s\n", $testcount, p($d), p($v), p($n));
    }
  } catch (Exception $e) {
    $errorcount++;
    printf("test %d exception: domain: %s\texpected: %s\tgot: %s\n", $testcount, p($d), p($v), p($n));
  }
}

//print_r(get_prevailing_suffix_rule('nancy.george.com.uk'));
eval(file_get_contents('/usr/share/doc/publicsuffix/examples/test_psl.txt'));

printf("%d errors total\n", $errorcount);

if ($errorcount > 0)
  exit(1);
else
  exit(0);
/*
 * Local Variables:
 * indent-tabs-mode: nil
 * c-basic-offset: 2
 * End:
 */