. # # Savane is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as # published by the Free Software Foundation, either version 3 of the # License, or (at your option) any later version. # # Savane is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . # # Invocation: # # php testing/utils.php # # In case of fail, diagnostic text is output to stdout. require_once ('include/utils.php'); $tests = [ 'a' => 'a', ':Admin;Savane"' => '":Admin;Savane\""', 'alice@savane.test' => '"alice@savane.test"', 'bob\\carol' => '"bob\\\\carol"' ]; foreach (str_split ('()<>@,;:.[]') as $c) { $s = "a{$c}b"; $tests[$s] = "\"$s\""; } foreach (str_split ('\\"') as $c) $tests["a{$c}b"] = '"a\\' . $c . 'b"'; foreach ($tests as $arg => $res) { $ret = utils_comply_with_rfc822 ($arg); if ($ret != $res) print "Unexpected result: $arg => $ret (expected $res)\n"; } ?>