1--TEST--
2Test convert_cyr_string() function : usage variations - test values for $str argument
3--FILE--
4<?php
5
6/* Prototype  : string convert_cyr_string  ( string $str  , string $from  , string $to  )
7 * Description: Convert from one Cyrillic character set to another
8 * Source code: ext/standard/string.c
9*/
10
11echo "*** Testing convert_cyr_string() function: with unexpected inputs for 'str' argument ***\n";
12
13//get an unset variable
14$unset_var = 'string_val';
15unset($unset_var);
16
17//defining a class
18class sample  {
19  public function __toString() {
20    return "sample object";
21  }
22}
23
24//getting the resource
25$file_handle = fopen(__FILE__, "r");
26
27// array with different values for $str
28$inputs =  array (
29
30		  // integer values
31/*1*/	  0,
32		  1,
33		  255,
34		  256,
35		  2147483647,
36		  -2147483648,
37
38		  // float values
39/*7*/	  10.5,
40		  -20.5,
41		  10.1234567e10,
42
43		  // array values
44/*10*/	  array(),
45		  array(0),
46		  array(1, 2),
47
48		  // boolean values
49/*13*/	  true,
50		  false,
51		  TRUE,
52		  FALSE,
53
54		  // null values
55/*17*/	  NULL,
56		  null,
57
58		  // objects
59/*19*/	  new sample(),
60
61		  // resource
62/*20*/	  $file_handle,
63
64		  // undefined variable
65/*21*/	  @$undefined_var,
66
67		  // unset variable
68/*22*/	  @$unset_var
69);
70
71// loop through with each element of the $inputs array to test convert_cyr_string() function
72$count = 1;
73$from = "w";
74$to = "k";
75foreach($inputs as $input) {
76  echo "-- Iteration $count --\n";
77  var_dump( convert_cyr_string($input, $from, $to) );
78  $count ++;
79}
80
81fclose($file_handle);  //closing the file handle
82
83?>
84===DONE===
85--EXPECTF--
86*** Testing convert_cyr_string() function: with unexpected inputs for 'str' argument ***
87-- Iteration 1 --
88string(1) "0"
89-- Iteration 2 --
90string(1) "1"
91-- Iteration 3 --
92string(3) "255"
93-- Iteration 4 --
94string(3) "256"
95-- Iteration 5 --
96string(10) "2147483647"
97-- Iteration 6 --
98string(11) "-2147483648"
99-- Iteration 7 --
100string(4) "10.5"
101-- Iteration 8 --
102string(5) "-20.5"
103-- Iteration 9 --
104string(12) "101234567000"
105-- Iteration 10 --
106
107Warning: convert_cyr_string() expects parameter 1 to be string, array given in %s on line %d
108NULL
109-- Iteration 11 --
110
111Warning: convert_cyr_string() expects parameter 1 to be string, array given in %s on line %d
112NULL
113-- Iteration 12 --
114
115Warning: convert_cyr_string() expects parameter 1 to be string, array given in %s on line %d
116NULL
117-- Iteration 13 --
118string(1) "1"
119-- Iteration 14 --
120string(0) ""
121-- Iteration 15 --
122string(1) "1"
123-- Iteration 16 --
124string(0) ""
125-- Iteration 17 --
126string(0) ""
127-- Iteration 18 --
128string(0) ""
129-- Iteration 19 --
130string(13) "sample object"
131-- Iteration 20 --
132
133Warning: convert_cyr_string() expects parameter 1 to be string, resource given in %s on line %d
134NULL
135-- Iteration 21 --
136string(0) ""
137-- Iteration 22 --
138string(0) ""
139===DONE===