From 078bcec0997ad0e07b720c43cc9e6d0e046a75ab Mon Sep 17 00:00:00 2001 From: SVN Migration Date: Thu, 27 Feb 2003 17:43:39 +0000 Subject: This commit was manufactured by cvs2svn to create branch 'PHP_5'. --- tests/testscanf.php | 113 ---------------------------------------------------- 1 file changed, 113 deletions(-) delete mode 100644 tests/testscanf.php (limited to 'tests/testscanf.php') diff --git a/tests/testscanf.php b/tests/testscanf.php deleted file mode 100644 index ad530978c5..0000000000 --- a/tests/testscanf.php +++ /dev/null @@ -1,113 +0,0 @@ -") { - if (is_array($val)) { - for ($i = 0;$i< count($val);$i++) { - echo $val[$i] . $postfix; - } - } else { - echo $val . $postfix; - } -} - -function do_sscanf($string, $format) { - $s = "sscanf(\"" . $string . ",\"" . $format ."\")."; - echo "$s
"; - $s = str_repeat("-", strlen($s)); - echo "$s
"; - $output = sscanf($string,$format); - echo "Result : "; - print_value( $output ); - echo "$s

"; -} - - -function run_sscanf_test_cases($filename="scan_cases") -{ - - echo "


Running Test Cases from $filename

"; - $arr = file($filename); - for ($i=0;$i < count($arr);$i++) { - $line_arr = explode("|",$arr[$i]); - - $format = $line_arr[0]; - $string = $line_arr[1]; - if (count($arr) > 2) { - $comment = $line_arr[2]; - } else { - $comment = ""; - } - if ( empty($format) || empty($string) ) { - continue; - } - print("

** Case : $comment ******************************

"); - do_sscanf($string,$format); - } -} - -function simple_tests() { - echo "Testing sscanf with standard ANSI syntax (values returned by -reference)-
"; - $decimal = -1; - $string = ""; - $hex = 0; - $float = 0.0; - $octal = 0.0; - $int = -1; - - echo "


Simple Test

"; - echo "sscanf('10','%d',&\$decimal)
"; - echo "
BEFORE :
decimal = $decimal."; - $foo = sscanf("10","%d",&$decimal); - echo "
AFTER :
decimal = $decimal
"; - - - echo "


Simple Test 2

"; - echo "sscanf(\"ghost 0xface\",\"%s %x\",&\$string, &\$int)
"; - echo "
BEFORE :
string = $string, int = $int
"; - $foo = sscanf("ghost 0xface","%s %x",&$string, &$int); - echo "
AFTER :
string = $string, int = $int
"; - echo " sscan reports : "; - print_value( $foo,""); - echo " conversions
"; - - echo "


Multiple specifiers

"; - echo "sscanf(\"jabberwocky 1024 0xFF 1.024 644 10\", - \"%s %d %x %f %o %i\", - &\$string,&\$decimal,&\$hex,&\$float,&\$octal,&\$int);
"; - echo "
BEFORE :
"; - echo "Decimal = $decimal, String = $string, Hex = $hex
"; - echo "Octal = $octal , Float = $float, Int = $int
"; - $foo = sscanf( "jabberwocky 1024 0xFF 1.024 644 10", - "%s %d %x %f %o %i", - &$string,&$decimal,&$hex,&$float,&$octal,&$int); - echo "
AFTER :
"; - echo "decimal = $decimal, string = $string, hex = $hex
"; - echo "octal = $octal , float = $float, int = $int
"; - - echo " sscan reports : "; - print_value( $foo,""); - echo " conversions
"; - echo "----------------------------------------
"; -} - - - -?> - - - Test of sscanf() - - -

Testing sscanf() support in PHP


- I'm sorry but sscanf() does not exist !i
"; - } else { - simple_tests(); - run_sscanf_test_cases(); - } - ?> - - -- cgit v1.2.1