示例#1
0
 protected function checkOutput($expected = null)
 {
     /* Check those output strings */
     $outp = $this->outputConnector->getData();
     if ($expected === null) {
         echo "\nOutput was:\n\"" . friendlyBinary($outp) . "\"\n";
     }
     $this->assertEquals($expected, $outp);
 }
示例#2
0
/**
 * Used in many of the tests to to output known-correct
 * strings for use in tests.
 */
function friendlyBinary($in)
{
    if (is_array($in)) {
        $out = array();
        foreach ($in as $line) {
            $out[] = friendlyBinary($line);
        }
        return "[" . implode(", ", $out) . "]";
    }
    if (strlen($in) == 0) {
        return $in;
    }
    /* Print out binary data with PHP \x00 escape codes,
    	 for builting test cases. */
    $chars = str_split($in);
    foreach ($chars as $i => $c) {
        $code = ord($c);
        if ($code < 32 || $code > 126) {
            $chars[$i] = "\\x" . bin2hex($c);
        }
    }
    return implode($chars);
}