-
Notifications
You must be signed in to change notification settings - Fork 3
/
tests.php
36 lines (28 loc) · 1.02 KB
/
tests.php
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
<?php
require_once 'plugin.php';
function yourls_add_filter($a, $b) { }
$fixture = array();
$fixture[] = array('127.0.0.1' => '127.0.0.0');
$fixture[] = array('192.0.43.10' => '192.0.43.0'); // example.com
$fixture[] = array('::1' => '::0');
$fixture[] = array('::ffff:127.0.0.1' => '::ffff:127.0.0.0');
$fixture[] = array('::ffff:192.0.43.10' => '::ffff:192.0.43.0');
$fixture[] = array('2001:0db8:85a3:0000:0000:8a2e:0370:7334' => '2001:0db8:85a3:0000:0000:8a2e:0370:0');
$success = TRUE;
echo "Running tests...\n";
for ($i = 0; $i <= count($fixture)-1; $i++) {
foreach ($fixture[$i] as $actual => $expected) {
$success &= assertEquals($expected, ubicoo_pseudonymize_IP( $actual ), $actual);
}
}
echo "Tests " . ($success ? "succeeded" : "failed") .".\n";
function assertEquals($expected, $actualAfter, $actualBefore)
{
echo " Checking $actualBefore => $expected ? ... ";
if ($actualAfter !== $expected) {
echo "FAILED - was $actualAfter\n";
return FALSE;
}
echo "OK\n";
return TRUE;
}