mirror of
https://github.com/ezyang/htmlpurifier.git
synced 2025-08-04 21:28:06 +02:00
Remove trailing whitespace.
Signed-off-by: Edward Z. Yang <edwardzyang@thewritingpot.com>
This commit is contained in:
@@ -2,23 +2,23 @@
|
||||
|
||||
class HTMLPurifier_UnitConverterTest extends HTMLPurifier_Harness
|
||||
{
|
||||
|
||||
|
||||
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",
|
||||
@@ -28,12 +28,12 @@ class HTMLPurifier_UnitConverterTest extends HTMLPurifier_Harness
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function testFail() {
|
||||
$this->assertConversion('1in', false, 'foo');
|
||||
$this->assertConversion('1foo', false, 'in');
|
||||
}
|
||||
|
||||
|
||||
function testZero() {
|
||||
$this->assertConversion('0', '0', 'in', false);
|
||||
$this->assertConversion('-0', '0', 'in', false);
|
||||
@@ -42,38 +42,38 @@ class HTMLPurifier_UnitConverterTest extends HTMLPurifier_Harness
|
||||
$this->assertConversion('0in', '0', 'pt', false);
|
||||
$this->assertConversion('-0in', '0', 'pt', false);
|
||||
}
|
||||
|
||||
|
||||
function testEnglish() {
|
||||
$this->assertConversion('1in', '6pc');
|
||||
$this->assertConversion('6pc', '1in');
|
||||
|
||||
|
||||
$this->assertConversion('1in', '72pt');
|
||||
$this->assertConversion('72pt', '1in');
|
||||
|
||||
|
||||
$this->assertConversion('1pc', '12pt');
|
||||
$this->assertConversion('12pt', '1pc');
|
||||
|
||||
|
||||
$this->assertConversion('1pt', '0.01389in');
|
||||
$this->assertConversion('1.000pt', '0.01389in');
|
||||
$this->assertConversion('100000pt', '1389in');
|
||||
|
||||
|
||||
$this->assertConversion('1in', '96px');
|
||||
$this->assertConversion('96px', '1in');
|
||||
}
|
||||
|
||||
|
||||
function testMetric() {
|
||||
$this->assertConversion('1cm', '10mm');
|
||||
$this->assertConversion('10mm', '1cm');
|
||||
$this->assertConversion('1mm', '0.1cm');
|
||||
$this->assertConversion('100mm', '10cm');
|
||||
}
|
||||
|
||||
|
||||
function testEnglishMetric() {
|
||||
$this->assertConversion('2.835pt', '1mm');
|
||||
$this->assertConversion('1mm', '2.835pt');
|
||||
$this->assertConversion('0.3937in', '1cm');
|
||||
}
|
||||
|
||||
|
||||
function testRoundingMinPrecision() {
|
||||
// One sig-fig, modified to be four, conversion rounds up
|
||||
$this->assertConversion('100pt', '1.389in');
|
||||
@@ -82,7 +82,7 @@ class HTMLPurifier_UnitConverterTest extends HTMLPurifier_Harness
|
||||
$this->assertConversion('100000pt', '1389in');
|
||||
$this->assertConversion('1000000pt', '13890in');
|
||||
}
|
||||
|
||||
|
||||
function testRoundingUserPrecision() {
|
||||
// Five sig-figs, conversion rounds down
|
||||
$this->assertConversion('11112000pt', '154330in');
|
||||
@@ -93,17 +93,17 @@ class HTMLPurifier_UnitConverterTest extends HTMLPurifier_Harness
|
||||
$this->assertConversion('111.12pt', '1.5433in');
|
||||
$this->assertConversion('11.112pt', '0.15433in');
|
||||
}
|
||||
|
||||
|
||||
function testRoundingBigNumber() {
|
||||
$this->assertConversion('444400000000000000000000in', '42660000000000000000000000px');
|
||||
}
|
||||
|
||||
|
||||
protected function assertSigFig($n, $sigfigs) {
|
||||
$converter = new HTMLPurifier_UnitConverter();
|
||||
$result = $converter->getSigFigs($n);
|
||||
$this->assertIdentical($result, $sigfigs);
|
||||
}
|
||||
|
||||
|
||||
function test_getSigFigs() {
|
||||
$this->assertSigFig('0', 0);
|
||||
$this->assertSigFig('1', 1);
|
||||
@@ -125,5 +125,5 @@ class HTMLPurifier_UnitConverterTest extends HTMLPurifier_Harness
|
||||
$this->assertSigFig('0.010', 2);
|
||||
$this->assertSigFig('0.012', 2);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user