mirror of
https://github.com/mrclay/minify.git
synced 2025-08-01 03:40:20 +02:00
+ compression ratios in Encoder tests
This commit is contained in:
@@ -20,8 +20,9 @@ function assertTrue($test, $message)
|
|||||||
if (!isset($count)) $count = array('pass'=>0, 'fail'=>0, 'total'=>0);
|
if (!isset($count)) $count = array('pass'=>0, 'fail'=>0, 'total'=>0);
|
||||||
|
|
||||||
$mode = $test ? 'pass' : 'fail';
|
$mode = $test ? 'pass' : 'fail';
|
||||||
|
$outMode = $test ? 'PASS' : '!FAIL';
|
||||||
printf("%s: %s (%d of %d tests run so far have %sed)\n",
|
printf("%s: %s (%d of %d tests run so far have %sed)\n",
|
||||||
strtoupper($mode), $message, ++$count[$mode], ++$count['total'], $mode);
|
$outMode, $message, ++$count[$mode], ++$count['total'], $mode);
|
||||||
|
|
||||||
return (bool)$test;
|
return (bool)$test;
|
||||||
}
|
}
|
||||||
|
@@ -69,10 +69,11 @@ function test_HTTP_Encoder()
|
|||||||
$variedContent = file_get_contents($thisDir . '/_test_files/html/before.html')
|
$variedContent = file_get_contents($thisDir . '/_test_files/html/before.html')
|
||||||
. file_get_contents($thisDir . '/_test_files/css/subsilver.css')
|
. file_get_contents($thisDir . '/_test_files/css/subsilver.css')
|
||||||
. file_get_contents($thisDir . '/../examples/1/jquery-1.2.3.js');
|
. file_get_contents($thisDir . '/../examples/1/jquery-1.2.3.js');
|
||||||
|
$variedLength = strlen($variedContent);
|
||||||
|
|
||||||
$encodingTests = array(
|
$encodingTests = array(
|
||||||
array('method' => 'gzip', 'exp' => 32174)
|
array('method' => 'deflate', 'exp' => 32156)
|
||||||
,array('method' => 'deflate', 'exp' => 32156)
|
,array('method' => 'gzip', 'exp' => 32174)
|
||||||
,array('method' => 'compress', 'exp' => 32210)
|
,array('method' => 'compress', 'exp' => 32210)
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -83,9 +84,11 @@ function test_HTTP_Encoder()
|
|||||||
));
|
));
|
||||||
$e->encode(9);
|
$e->encode(9);
|
||||||
$ret = strlen($e->getContent());
|
$ret = strlen($e->getContent());
|
||||||
|
|
||||||
|
$desc = "HTTP_Encoder : {$test['method']} -> "
|
||||||
|
. sprintf('%4.2f%%', $ret/$variedLength*100);
|
||||||
|
|
||||||
$passed = assertTrue($ret == $test['exp']
|
$passed = assertTrue($ret == $test['exp'], $desc);
|
||||||
,"HTTP_Encoder : {$test['method']} compression");
|
|
||||||
|
|
||||||
if (__FILE__ === $_SERVER['SCRIPT_FILENAME']) {
|
if (__FILE__ === $_SERVER['SCRIPT_FILENAME']) {
|
||||||
echo "\n--- {$test['method']}: expected bytes: "
|
echo "\n--- {$test['method']}: expected bytes: "
|
||||||
|
Reference in New Issue
Block a user