mirror of
https://github.com/mrclay/minify.git
synced 2025-04-21 04:41:54 +02:00
+ compression ratios in Encoder tests
This commit is contained in:
parent
e2ad73f8be
commit
98530fcd57
@ -20,8 +20,9 @@ function assertTrue($test, $message)
|
||||
if (!isset($count)) $count = array('pass'=>0, 'fail'=>0, 'total'=>0);
|
||||
|
||||
$mode = $test ? 'pass' : 'fail';
|
||||
$outMode = $test ? 'PASS' : '!FAIL';
|
||||
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;
|
||||
}
|
||||
|
@ -69,10 +69,11 @@ function test_HTTP_Encoder()
|
||||
$variedContent = file_get_contents($thisDir . '/_test_files/html/before.html')
|
||||
. file_get_contents($thisDir . '/_test_files/css/subsilver.css')
|
||||
. file_get_contents($thisDir . '/../examples/1/jquery-1.2.3.js');
|
||||
$variedLength = strlen($variedContent);
|
||||
|
||||
$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)
|
||||
);
|
||||
|
||||
@ -83,9 +84,11 @@ function test_HTTP_Encoder()
|
||||
));
|
||||
$e->encode(9);
|
||||
$ret = strlen($e->getContent());
|
||||
|
||||
$desc = "HTTP_Encoder : {$test['method']} -> "
|
||||
. sprintf('%4.2f%%', $ret/$variedLength*100);
|
||||
|
||||
$passed = assertTrue($ret == $test['exp']
|
||||
,"HTTP_Encoder : {$test['method']} compression");
|
||||
$passed = assertTrue($ret == $test['exp'], $desc);
|
||||
|
||||
if (__FILE__ === $_SERVER['SCRIPT_FILENAME']) {
|
||||
echo "\n--- {$test['method']}: expected bytes: "
|
||||
|
Loading…
x
Reference in New Issue
Block a user