From 98530fcd57597c8cc3b611911ea1496c601697c5 Mon Sep 17 00:00:00 2001 From: Steve Clay Date: Tue, 4 Mar 2008 22:02:57 +0000 Subject: [PATCH] + compression ratios in Encoder tests --- web/test/_inc.php | 3 ++- web/test/test_HTTP_Encoder.php | 11 +++++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/web/test/_inc.php b/web/test/_inc.php index 1a724d1..c6bd553 100644 --- a/web/test/_inc.php +++ b/web/test/_inc.php @@ -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; } diff --git a/web/test/test_HTTP_Encoder.php b/web/test/test_HTTP_Encoder.php index 30e4262..d231d38 100644 --- a/web/test/test_HTTP_Encoder.php +++ b/web/test/test_HTTP_Encoder.php @@ -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: "