Annotation of embedaddon/php/ext/standard/tests/strings/strspn_variation5.phpt, revision 1.1.1.1

1.1       misho       1: --TEST--
                      2: Test strspn() function : usage variations - with heredoc strings with default start and len args
                      3: --FILE--
                      4: <?php
                      5: /* Prototype  : proto int strspn(string str, string mask [, int start [, int len]])
                      6:  * Description: Finds length of initial segment consisting entirely of characters found in mask.
                      7:                 If start or/and length is provided works like strspn(substr($s,$start,$len),$good_chars) 
                      8:  * Source code: ext/standard/string.c
                      9:  * Alias to functions: none
                     10: */
                     11: 
                     12: /*
                     13: * Testing strspn() : with different heredoc strings as str argument
                     14: */
                     15: 
                     16: echo "*** Testing strspn() : with heredoc strings ***\n";
                     17: 
                     18: // initialing required variables
                     19: // defining different heredoc strings
                     20: $empty_heredoc = <<<EOT
                     21: EOT;
                     22: 
                     23: $heredoc_with_newline = <<<EOT
                     24: \n
                     25: 
                     26: EOT;
                     27: 
                     28: $heredoc_with_characters = <<<EOT
                     29: first line of heredoc string
                     30: second line of heredoc string
                     31: third line of heredocstring
                     32: EOT;
                     33: 
                     34: $heredoc_with_newline_and_tabs = <<<EOT
                     35: hello\tworld\nhello\nworld\n
                     36: EOT;
                     37: 
                     38: $heredoc_with_alphanumerics = <<<EOT
                     39: hello123world456
                     40: 1234hello\t1234
                     41: EOT;
                     42: 
                     43: $heredoc_with_embedded_nulls = <<<EOT
                     44: hello\0world\0hello
                     45: \0hello\0
                     46: EOT;
                     47: 
                     48: $heredoc_with_hexa_octal = <<<EOT
                     49: hello\0\100\xaaworld\0hello
                     50: \0hello\0
                     51: EOT;
                     52: 
                     53: $heredoc_strings = array(
                     54:                    $empty_heredoc,
                     55:                    $heredoc_with_newline,
                     56:                    $heredoc_with_characters,
                     57:                    $heredoc_with_newline_and_tabs,
                     58:                    $heredoc_with_alphanumerics,
                     59:                    $heredoc_with_embedded_nulls,
                     60:                    $heredoc_with_hexa_octal
                     61:                    );
                     62: 
                     63: $mask = "sfth12\ne34l567890\0\xaa\100o";
                     64: 
                     65: 
                     66: // loop through each element of the array for str argument
                     67: 
                     68: foreach($heredoc_strings as $str) {
                     69:       echo "\n-- Iteration with str value as \"$str\" --\n";
                     70:       var_dump( strspn($str,$mask) ); // with default start and len values
                     71: };
                     72: 
                     73: echo "Done"
                     74: ?>
                     75: --EXPECTF--
                     76: *** Testing strspn() : with heredoc strings ***
                     77: 
                     78: -- Iteration with str value as "" --
                     79: int(0)
                     80: 
                     81: -- Iteration with str value as "
                     82: 
                     83: " --
                     84: int(2)
                     85: 
                     86: -- Iteration with str value as "first line of heredoc string
                     87: second line of heredoc string
                     88: third line of heredocstring" --
                     89: int(1)
                     90: 
                     91: -- Iteration with str value as "hello  world
                     92: hello
                     93: world
                     94: " --
                     95: int(5)
                     96: 
                     97: -- Iteration with str value as "hello123world456
                     98: 1234hello      1234" --
                     99: int(8)
                    100: 
                    101: -- Iteration with str value as "helloworldhello
                    102: hello" --
                    103: int(6)
                    104: 
                    105: -- Iteration with str value as "hello@ªworldhello
                    106: hello" --
                    107: int(8)
                    108: Done

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>