protected function assertConversion($input, $expect, $unit = null, $test_negative = true)
{
$length = HTMLPurifier_Length::make($input);
if ($expect !== false) {
$expectl = HTMLPurifier_Length::make($expect);
} else {
$expectl = false;
}
$to_unit = $unit !== null ? $unit : $expectl->getUnit();
$converter = new HTMLPurifier_UnitConverter(4, 10);
$result = $converter->convert($length, $to_unit);
if (!$result || !$expectl) {
$this->assertIdentical($result, $expectl);
} else {
$this->assertIdentical($result->toString(), $expectl->toString());
}
$converter = new HTMLPurifier_UnitConverter(4, 10, true);
$result = $converter->convert($length, $to_unit);
if (!$result || !$expectl) {
$this->assertIdentical($result, $expectl);
} else {
$this->assertIdentical($result->toString(), $expectl->toString(), 'BCMath substitute: %s');
}
if ($test_negative) {
$this->assertConversion("-{$input}", $expect === false ? false : "-{$expect}", $unit, false);
}
}