diff options
author | Stig Bakken <ssb@php.net> | 2000-08-27 19:46:06 +0000 |
---|---|---|
committer | Stig Bakken <ssb@php.net> | 2000-08-27 19:46:06 +0000 |
commit | 315f4f5658cf22a17ba06fa2ca2f3d890355873f (patch) | |
tree | 3dd1134c1d1c3821b48fab806884123f09b2d21f /ext/interbase/tests/interbase.inc | |
parent | 7eeda99a055df5a510d3d20526e9adcb42fecdb0 (diff) | |
download | php-git-315f4f5658cf22a17ba06fa2ca2f3d890355873f.tar.gz |
@PHP 3 regression testing framework re-born (Stig)
Took the old PHP 3 regression testing framework and rewrote it in PHP.
Should work on both Windows and UNIX, however I have not tested it on
Windows. See tests/README for how to write tests. Added the PHP 3
tests and converted most of them.
Diffstat (limited to 'ext/interbase/tests/interbase.inc')
-rwxr-xr-x | ext/interbase/tests/interbase.inc | 77 |
1 files changed, 77 insertions, 0 deletions
diff --git a/ext/interbase/tests/interbase.inc b/ext/interbase/tests/interbase.inc new file mode 100755 index 0000000000..f261cb01b5 --- /dev/null +++ b/ext/interbase/tests/interbase.inc @@ -0,0 +1,77 @@ +<? +/* $Id$ */ +/* used in tests */ + +srand((double)microtime()*1000000); + +function out_table($table_name) +{ + echo "--- $table_name ---\n"; + $res = ibase_query("select * from $table_name"); + $f = ibase_num_fields($res); + while ($r = ibase_fetch_row($res)){ + for($i = 0; $i < $f; $i++) + echo "$r[$i]\t"; + echo "\n"; + } + ibase_free_result($res); + echo "---\n"; +} + +function out_result($result, $table_name = "") +{ + echo "--- $table_name ---\n"; + $f = ibase_num_fields($result); + while ($r = ibase_fetch_row($result)){ + for($i = 0; $i < $f; $i++) + echo "$r[$i]\t"; + echo "\n"; + } + echo "---\n"; +} + +/* M/D/Y H:M:S */ +function rand_datetime() +{ + return sprintf("%02d/%02d/%4d %02d:%02d:%02d", + rand()%12+1, rand()%28+1, rand()%100+1910, + rand()%24, rand()%60, rand()%60); +} + +/* random binary string */ +function rand_binstr($max_len) +{ + $len = rand() % $max_len; + $s = ""; + while($len--) + $s .= sprintf("%c", rand() % 256); + return $s; +} + +function rand_str($max_len) +{ + $len = rand() % $max_len; + $s = ""; + while($len--) + $s .= sprintf("%c", rand() % 26 + 65);; + return $s; +} + +function rand_number($len , $prec = -1, $sign = 1) +{ + if($prec == -1){ + $n = substr(rand() . rand(), 0, rand() % $len + 1); + if(strlen($n) < $len) + $n .= "." . substr(rand(), 0, rand() % ($len - strlen($n)) + 1); + }elseif ($prec == 0){ + $n = substr(rand() . rand(), 0, rand() % $len + 1); + }else{ + $n = substr(rand() . rand(), 0, rand() % ($len - $prec) + 1); + $n .= "." . substr(rand(), 0, $prec); + } + if($sign && (rand() % 3 == 0)) + $n = "-" .$n; + return $n; +} + +?>
\ No newline at end of file |