nicholsr                Fri Jan 25 00:17:34 2008 UTC

  Modified files:              
    /php-src/ext/standard/tests/array   array_udiff_basic.phpt 
                                        array_uintersect_assoc_basic.phpt 
                                        array_diff_uassoc_basic.phpt 
                                        array_diff_key_variation1.phpt 
                                        array_intersect_uassoc_basic.phpt 
                                        array_uintersect_basic.phpt 
                                        array_diff_ukey_basic.phpt 
                                        array_intersect_ukey_basic.phpt 
                                        array_udiff_assoc_basic.phpt 
                                        array_intersect_key_basic.phpt 
                                        array_udiff_uassoc_basic.phpt 
                                        array_uintersect_uassoc_basic.phpt 
                                        array_diff_key_basic.phpt 
  Log:
  - add some basic tests for array diff and intersection functions
  
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/array/array_udiff_basic.phpt?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/standard/tests/array/array_udiff_basic.phpt
diff -u /dev/null php-src/ext/standard/tests/array/array_udiff_basic.phpt:1.2
--- /dev/null   Fri Jan 25 00:17:34 2008
+++ php-src/ext/standard/tests/array/array_udiff_basic.phpt     Fri Jan 25 
00:17:34 2008
@@ -0,0 +1,49 @@
+--TEST--
+array_udiff():Test return type and value for expected input 
+--FILE--
+<?php
+/*
+* proto array array_udiff ( array $array1, array $array2 [, array $ ..., 
callback $data_compare_func] )
+* Function is implemented in ext/standard/array.c
+*/
+class cr {
+    private $priv_member;
+    function cr($val) {
+        $this->priv_member = $val;
+    }
+    static function comp_func_cr($a, $b) {
+        if ($a->priv_member === $b->priv_member) return 0;
+        return ($a->priv_member > $b->priv_member) ? 1 : -1;
+    }
+}
+$a = array("0.1" => new cr(9), "0.5" => new cr(12), 0 => new cr(23), 1 => new 
cr(4), 2 => new cr(-15),);
+$b = array("0.2" => new cr(9), "0.5" => new cr(22), 0 => new cr(3), 1 => new 
cr(4), 2 => new cr(-15),);
+$result = array_udiff($a, $b, array("cr", "comp_func_cr"));
+var_dump($result);
+?>
+--EXPECTF--
+array(2) {
+  ["0.5"]=>
+  object(cr)#%d (1) {
+    ["priv_member":"cr":private]=>
+    int(12)
+  }
+  [0]=>
+  object(cr)#%d (1) {
+    ["priv_member":"cr":private]=>
+    int(23)
+  }
+}
+--UEXPECTF--
+array(2) {
+  [u"0.5"]=>
+  object(cr)#%d (1) {
+    [u"priv_member":u"cr":private]=>
+    int(12)
+  }
+  [0]=>
+  object(cr)#%d (1) {
+    [u"priv_member":u"cr":private]=>
+    int(23)
+  }
+}
\ No newline at end of file
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/array/array_uintersect_assoc_basic.phpt?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/standard/tests/array/array_uintersect_assoc_basic.phpt
diff -u /dev/null 
php-src/ext/standard/tests/array/array_uintersect_assoc_basic.phpt:1.2
--- /dev/null   Fri Jan 25 00:17:34 2008
+++ php-src/ext/standard/tests/array/array_uintersect_assoc_basic.phpt  Fri Jan 
25 00:17:34 2008
@@ -0,0 +1,49 @@
+--TEST--
+array_uintersect_assoc(): Test return type and value for expected input 
+--FILE--
+<?php
+/*
+* proto array array_uintersect_assoc ( array $array1, array $array2 [, array $ 
..., callback $data_compare_func] )
+* Function is implemented in ext/standard/array.c
+*/
+class cr {
+    private $priv_member;
+    function cr($val) {
+        $this->priv_member = $val;
+    }
+    static function comp_func_cr($a, $b) {
+        if ($a->priv_member === $b->priv_member) return 0;
+        return ($a->priv_member > $b->priv_member) ? 1 : -1;
+    }
+}
+$a = array("0.1" => new cr(9), "0.5" => new cr(12), 0 => new cr(23), 1 => new 
cr(4), 2 => new cr(-15),);
+$b = array("0.2" => new cr(9), "0.5" => new cr(22), 0 => new cr(3), 1 => new 
cr(4), 2 => new cr(-15),);
+$result = array_uintersect_assoc($a, $b, array("cr", "comp_func_cr"));
+var_dump($result);
+?>
+--EXPECTF--
+array(2) {
+  [1]=>
+  object(cr)#%d (1) {
+    ["priv_member":"cr":private]=>
+    int(4)
+  }
+  [2]=>
+  object(cr)#%d (1) {
+    ["priv_member":"cr":private]=>
+    int(-15)
+  }
+}
+--UEXPECTF--
+array(2) {
+  [1]=>
+  object(cr)#%d (1) {
+    [u"priv_member":u"cr":private]=>
+    int(4)
+  }
+  [2]=>
+  object(cr)#%d (1) {
+    [u"priv_member":u"cr":private]=>
+    int(-15)
+  }
+}
\ No newline at end of file
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/array/array_diff_uassoc_basic.phpt?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/standard/tests/array/array_diff_uassoc_basic.phpt
diff -u /dev/null 
php-src/ext/standard/tests/array/array_diff_uassoc_basic.phpt:1.2
--- /dev/null   Fri Jan 25 00:17:34 2008
+++ php-src/ext/standard/tests/array/array_diff_uassoc_basic.phpt       Fri Jan 
25 00:17:34 2008
@@ -0,0 +1,37 @@
+--TEST--
+array_diff_uassoc(): Basic test 
+--FILE--
+<?php
+/*
+* array array_diff_uassoc ( array $array1, array $array2 [, array $..., 
callback $key_compare_func] )
+* Function is implemented in ext/standard/array.c
+*/
+function key_compare_func($a, $b) {
+    if ($a === $b) {
+        return 0;
+    }
+    return ($a > $b) ? 1 : -1;
+}
+$array1 = array("a" => "green", "b" => "brown", "c" => "blue", "red");
+$array2 = array("a" => "green", "yellow", "red");
+$result = array_diff_uassoc($array1, $array2, "key_compare_func");
+var_dump($result);
+?>
+--EXPECT--
+array(3) {
+  ["b"]=>
+  string(5) "brown"
+  ["c"]=>
+  string(4) "blue"
+  [0]=>
+  string(3) "red"
+}
+--UEXPECT--
+array(3) {
+  [u"b"]=>
+  unicode(5) "brown"
+  [u"c"]=>
+  unicode(4) "blue"
+  [0]=>
+  unicode(3) "red"
+}
\ No newline at end of file
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/array/array_diff_key_variation1.phpt?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/standard/tests/array/array_diff_key_variation1.phpt
diff -u /dev/null 
php-src/ext/standard/tests/array/array_diff_key_variation1.phpt:1.2
--- /dev/null   Fri Jan 25 00:17:34 2008
+++ php-src/ext/standard/tests/array/array_diff_key_variation1.phpt     Fri Jan 
25 00:17:34 2008
@@ -0,0 +1,89 @@
+--TEST--
+array_diff_key() : type variations 
+--FILE--
+<?php
+/*
+* proto array array_diff_key(array arr1, array arr2 [, array ...])
+* Function is implemented in ext/standard/array.c
+*/
+/*
+* Testing how array_diff_key treats keys that are numbers, floating point 
numbers or strings.
+*/
+$arr1 = array(1 => 'a', 2 => 'b', 3 => 'c', 'key1' => 'value');
+$arr2 = array(1.00 => 'a', 2.00 => 'b', 3.00 => 'c', 'key2' => 'value');
+$arr3 = array('1' => 'a', '2' => 'b', '3' => 'c', 'key3' => 'value');
+$arr4 = array('1.00' => 'a', '2.00' => 'b', '3.00' => 'c', 'key4' => 'value'); 
//$arr4 looks different to the other three arrays.
+print "Result of comparing integers and floating point value:\n"; //1 and 1.00 
are treated as the same thing
+print_r(array_diff_key($arr1, $arr2));
+print_r(array_diff_key($arr2, $arr1));
+print "Result of comparing integers and strings containing an integers:\n"; 
//1 and the string 1 are treated as the same thing
+print_r(array_diff_key($arr1, $arr3));
+print_r(array_diff_key($arr3, $arr1));
+print "Result of comparing integers and strings containing floating 
points:\n"; //1 and the string 1.00 are not treated as the same thing
+print_r(array_diff_key($arr1, $arr4));
+print_r(array_diff_key($arr4, $arr1));
+print "Result of comparing floating points and strings containing integers:\n";
+print_r(array_diff_key($arr2, $arr3)); //1.00 and the string 1 are treated as 
the same thing
+print_r(array_diff_key($arr3, $arr2));
+print "Result of comparing strings containing integers and strings containing 
floating points:\n"; //the strings 1 and 1.00 are not treated as the same thing.
+print_r(array_diff_key($arr3, $arr4));
+print_r(array_diff_key($arr4, $arr3));
+?>
+--EXPECTF--
+Result of comparing integers and floating point value:
+Array
+(
+    [key1] => value
+)
+Array
+(
+    [key2] => value
+)
+Result of comparing integers and strings containing an integers:
+Array
+(
+    [key1] => value
+)
+Array
+(
+    [key3] => value
+)
+Result of comparing integers and strings containing floating points:
+Array
+(
+    [1] => a
+    [2] => b
+    [3] => c
+    [key1] => value
+)
+Array
+(
+    [1.00] => a
+    [2.00] => b
+    [3.00] => c
+    [key4] => value
+)
+Result of comparing floating points and strings containing integers:
+Array
+(
+    [key2] => value
+)
+Array
+(
+    [key3] => value
+)
+Result of comparing strings containing integers and strings containing 
floating points:
+Array
+(
+    [1] => a
+    [2] => b
+    [3] => c
+    [key3] => value
+)
+Array
+(
+    [1.00] => a
+    [2.00] => b
+    [3.00] => c
+    [key4] => value
+)
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/array/array_intersect_uassoc_basic.phpt?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/standard/tests/array/array_intersect_uassoc_basic.phpt
diff -u /dev/null 
php-src/ext/standard/tests/array/array_intersect_uassoc_basic.phpt:1.2
--- /dev/null   Fri Jan 25 00:17:34 2008
+++ php-src/ext/standard/tests/array/array_intersect_uassoc_basic.phpt  Fri Jan 
25 00:17:34 2008
@@ -0,0 +1,29 @@
+--TEST--
+array_intersect_uassoc(): Basic test
+--FILE--
+<?php
+/*
+* array array_intersect_uassoc ( array $array1, array $array2 [, array $..., 
callback $key_compare_func] )
+* Function is implemented in ext/standard/array.c
+*/
+function key_compare_func($a, $b) {
+    if ($a === $b) {
+        return 0;
+    }
+    return ($a > $b) ? 1 : -1;
+}
+$array1 = array("a" => "green", "b" => "brown", "c" => "blue", "red");
+$array2 = array("a" => "green", "yellow", "red");
+$result = array_intersect_uassoc($array1, $array2, "key_compare_func");
+var_dump($result);
+?>
+--EXPECT--
+array(1) {
+  ["a"]=>
+  string(5) "green"
+}
+--UEXPECT--
+array(1) {
+  [u"a"]=>
+  unicode(5) "green"
+}
\ No newline at end of file
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/array/array_uintersect_basic.phpt?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/standard/tests/array/array_uintersect_basic.phpt
diff -u /dev/null 
php-src/ext/standard/tests/array/array_uintersect_basic.phpt:1.2
--- /dev/null   Fri Jan 25 00:17:34 2008
+++ php-src/ext/standard/tests/array/array_uintersect_basic.phpt        Fri Jan 
25 00:17:34 2008
@@ -0,0 +1,59 @@
+--TEST--
+array_uintersect(): Test return type and value for expected input 
+--FILE--
+<?php
+/*
+* proto array array_uintersect ( array $array1, array $array2 [, array $ ..., 
callback $data_compare_func] )
+* Function is implemented in ext/standard/array.c
+*/
+class cr {
+    private $priv_member;
+    function cr($val) {
+        $this->priv_member = $val;
+    }
+    static function comp_func_cr($a, $b) {
+        if ($a->priv_member === $b->priv_member) return 0;
+        return ($a->priv_member > $b->priv_member) ? 1 : -1;
+    }
+}
+$a = array("0.1" => new cr(9), "0.5" => new cr(12), 0 => new cr(23), 1 => new 
cr(4), 2 => new cr(-15),);
+$b = array("0.2" => new cr(9), "0.5" => new cr(22), 0 => new cr(3), 1 => new 
cr(4), 2 => new cr(-15),);
+$result = array_uintersect($a, $b, array("cr", "comp_func_cr"));
+var_dump($result);
+?>
+--EXPECTF--
+array(3) {
+  ["0.1"]=>
+  object(cr)#%d (1) {
+    ["priv_member":"cr":private]=>
+    int(9)
+  }
+  [1]=>
+  object(cr)#%d (1) {
+    ["priv_member":"cr":private]=>
+    int(4)
+  }
+  [2]=>
+  object(cr)#%d (1) {
+    ["priv_member":"cr":private]=>
+    int(-15)
+  }
+}
+--UEXPECTF--
+array(3) {
+  [u"0.1"]=>
+  object(cr)#%d (1) {
+    [u"priv_member":u"cr":private]=>
+    int(9)
+  }
+  [1]=>
+  object(cr)#%d (1) {
+    [u"priv_member":u"cr":private]=>
+    int(4)
+  }
+  [2]=>
+  object(cr)#%d (1) {
+    [u"priv_member":u"cr":private]=>
+    int(-15)
+  }
+}
\ No newline at end of file
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/array/array_diff_ukey_basic.phpt?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/standard/tests/array/array_diff_ukey_basic.phpt
diff -u /dev/null 
php-src/ext/standard/tests/array/array_diff_ukey_basic.phpt:1.2
--- /dev/null   Fri Jan 25 00:17:34 2008
+++ php-src/ext/standard/tests/array/array_diff_ukey_basic.phpt Fri Jan 25 
00:17:34 2008
@@ -0,0 +1,31 @@
+--TEST--
+array_diff_ukey() : Basic test. 
+--FILE--
+<?php
+/*
+* proto array array_diff_ukey ( array $array1, array $array2 [, array $ ..., 
callback $key_compare_func] )
+* Function is implemented in ext/standard/array.c
+*/
+function key_compare_func($key1, $key2) {
+    if ($key1 == $key2) return 0;
+    else if ($key1 > $key2) return 1;
+    else return -1;
+}
+$array1 = array('blue' => 1, 'red' => 2, 'green' => 3, 'purple' => 4);
+$array2 = array('green' => 5, 'blue' => 6, 'yellow' => 7, 'cyan' => 8);
+var_dump(array_diff_ukey($array1, $array2, 'key_compare_func'));
+?>
+--EXPECT--
+array(2) {
+  ["red"]=>
+  int(2)
+  ["purple"]=>
+  int(4)
+}
+--UEXPECT--
+array(2) {
+  [u"red"]=>
+  int(2)
+  [u"purple"]=>
+  int(4)
+}
\ No newline at end of file
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/array/array_intersect_ukey_basic.phpt?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/standard/tests/array/array_intersect_ukey_basic.phpt
diff -u /dev/null 
php-src/ext/standard/tests/array/array_intersect_ukey_basic.phpt:1.2
--- /dev/null   Fri Jan 25 00:17:34 2008
+++ php-src/ext/standard/tests/array/array_intersect_ukey_basic.phpt    Fri Jan 
25 00:17:34 2008
@@ -0,0 +1,31 @@
+--TEST--
+array_intersect_ukey(): Basic test.  
+--FILE--
+<?php
+/*
+* proto array array_intersect_ukey ( array $array1, array $array2 [, array $ 
..., callback $key_compare_func] )
+* Function is implemented in ext/standard/array.c
+*/
+function key_compare_func($key1, $key2) {
+    if ($key1 == $key2) return 0;
+    else if ($key1 > $key2) return 1;
+    else return -1;
+}
+$array1 = array('blue' => 1, 'red' => 2, 'green' => 3, 'purple' => 4);
+$array2 = array('green' => 5, 'blue' => 6, 'yellow' => 7, 'cyan' => 8);
+var_dump(array_intersect_ukey($array1, $array2, 'key_compare_func'));
+?>
+--EXPECT--
+array(2) {
+  ["blue"]=>
+  int(1)
+  ["green"]=>
+  int(3)
+}
+--UEXPECT--
+array(2) {
+  [u"blue"]=>
+  int(1)
+  [u"green"]=>
+  int(3)
+}
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/array/array_udiff_assoc_basic.phpt?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/standard/tests/array/array_udiff_assoc_basic.phpt
diff -u /dev/null 
php-src/ext/standard/tests/array/array_udiff_assoc_basic.phpt:1.2
--- /dev/null   Fri Jan 25 00:17:34 2008
+++ php-src/ext/standard/tests/array/array_udiff_assoc_basic.phpt       Fri Jan 
25 00:17:34 2008
@@ -0,0 +1,59 @@
+--TEST--
+array_udiff_assoc(): Test return type and value for expected input 
+--FILE--
+<?php
+/*
+* proto array array_udiff_assoc ( array $array1, array $array2 [, array $ ..., 
callback $data_compare_func] )
+* Function is implemented in ext/standard/array.c
+*/
+class cr {
+    private $priv_member;
+    function cr($val) {
+        $this->priv_member = $val;
+    }
+    static function comp_func_cr($a, $b) {
+        if ($a->priv_member === $b->priv_member) return 0;
+        return ($a->priv_member > $b->priv_member) ? 1 : -1;
+    }
+}
+$a = array("0.1" => new cr(9), "0.5" => new cr(12), 0 => new cr(23), 1 => new 
cr(4), 2 => new cr(-15),);
+$b = array("0.2" => new cr(9), "0.5" => new cr(22), 0 => new cr(3), 1 => new 
cr(4), 2 => new cr(-15),);
+$result = array_udiff_assoc($a, $b, array("cr", "comp_func_cr"));
+var_dump($result);
+?>
+--EXPECTF--
+array(3) {
+  ["0.1"]=>
+  object(cr)#%d (1) {
+    ["priv_member":"cr":private]=>
+    int(9)
+  }
+  ["0.5"]=>
+  object(cr)#%d (1) {
+    ["priv_member":"cr":private]=>
+    int(12)
+  }
+  [0]=>
+  object(cr)#%d (1) {
+    ["priv_member":"cr":private]=>
+    int(23)
+  }
+}
+--UEXPECTF--
+array(3) {
+  [u"0.1"]=>
+  object(cr)#%d (1) {
+    [u"priv_member":u"cr":private]=>
+    int(9)
+  }
+  [u"0.5"]=>
+  object(cr)#%d (1) {
+    [u"priv_member":u"cr":private]=>
+    int(12)
+  }
+  [0]=>
+  object(cr)#%d (1) {
+    [u"priv_member":u"cr":private]=>
+    int(23)
+  }
+}
\ No newline at end of file
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/array/array_intersect_key_basic.phpt?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/standard/tests/array/array_intersect_key_basic.phpt
diff -u /dev/null 
php-src/ext/standard/tests/array/array_intersect_key_basic.phpt:1.2
--- /dev/null   Fri Jan 25 00:17:34 2008
+++ php-src/ext/standard/tests/array/array_intersect_key_basic.phpt     Fri Jan 
25 00:17:34 2008
@@ -0,0 +1,26 @@
+--TEST--
+array_intersect_key(): Basic Test  
+--FILE--
+<?php
+/*
+* proto array array_intersect_key(array arr1, array arr2 [, array ...])
+* Function is implemented in ext/standard/array.c
+*/
+$array1 = array('blue' => 1, 'red' => 2, 'green' => 3, 'purple' => 4);
+$array2 = array('green' => 5, 'blue' => 6, 'yellow' => 7, 'cyan' => 8);
+var_dump(array_intersect_key($array1, $array2));
+?>
+--EXPECT--
+array(2) {
+  ["blue"]=>
+  int(1)
+  ["green"]=>
+  int(3)
+}
+--UEXPECT--
+array(2) {
+  [u"blue"]=>
+  int(1)
+  [u"green"]=>
+  int(3)
+}
\ No newline at end of file
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/array/array_udiff_uassoc_basic.phpt?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/standard/tests/array/array_udiff_uassoc_basic.phpt
diff -u /dev/null 
php-src/ext/standard/tests/array/array_udiff_uassoc_basic.phpt:1.2
--- /dev/null   Fri Jan 25 00:17:34 2008
+++ php-src/ext/standard/tests/array/array_udiff_uassoc_basic.phpt      Fri Jan 
25 00:17:34 2008
@@ -0,0 +1,63 @@
+--TEST--
+array_udiff_uassoc(): Test return type and value for expected input 
+--FILE--
+<?php
+/*
+* proto array array_udiff_assoc ( array $array1, array $array2 [, array $ ..., 
callback $data_compare_func] )
+* Function is implemented in ext/standard/array.c
+*/
+class cr {
+    private $priv_member;
+    function cr($val) {
+        $this->priv_member = $val;
+    }
+    static function comp_func_cr($a, $b) {
+        if ($a->priv_member === $b->priv_member) return 0;
+        return ($a->priv_member > $b->priv_member) ? 1 : -1;
+    }
+    static function comp_func_key($a, $b) {
+        if ($a === $b) return 0;
+        return ($a > $b) ? 1 : -1;
+    }
+}
+$a = array("0.1" => new cr(9), "0.5" => new cr(12), 0 => new cr(23), 1 => new 
cr(4), 2 => new cr(-15),);
+$b = array("0.2" => new cr(9), "0.5" => new cr(22), 0 => new cr(3), 1 => new 
cr(4), 2 => new cr(-15),);
+$result = array_udiff_uassoc($a, $b, array("cr", "comp_func_cr"), array("cr", 
"comp_func_key"));
+var_dump($result);
+?>
+--EXPECTF--
+array(3) {
+  ["0.1"]=>
+  object(cr)#%d (1) {
+    ["priv_member":"cr":private]=>
+    int(9)
+  }
+  ["0.5"]=>
+  object(cr)#%d (1) {
+    ["priv_member":"cr":private]=>
+    int(12)
+  }
+  [0]=>
+  object(cr)#%d (1) {
+    ["priv_member":"cr":private]=>
+    int(23)
+  }
+}
+--UEXPECTF--
+array(3) {
+  [u"0.1"]=>
+  object(cr)#%d (1) {
+    [u"priv_member":u"cr":private]=>
+    int(9)
+  }
+  [u"0.5"]=>
+  object(cr)#%d (1) {
+    [u"priv_member":u"cr":private]=>
+    int(12)
+  }
+  [0]=>
+  object(cr)#%d (1) {
+    [u"priv_member":u"cr":private]=>
+    int(23)
+  }
+}
\ No newline at end of file
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/array/array_uintersect_uassoc_basic.phpt?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/standard/tests/array/array_uintersect_uassoc_basic.phpt
diff -u /dev/null 
php-src/ext/standard/tests/array/array_uintersect_uassoc_basic.phpt:1.2
--- /dev/null   Fri Jan 25 00:17:34 2008
+++ php-src/ext/standard/tests/array/array_uintersect_uassoc_basic.phpt Fri Jan 
25 00:17:34 2008
@@ -0,0 +1,53 @@
+--TEST--
+array_uintersect_uassoc(): Test return type and value for expected input 
+--FILE--
+<?php
+/*
+* proto array array_uintersect_assoc ( array $array1, array $array2 [, array $ 
..., callback $data_compare_func] )
+* Function is implemented in ext/standard/array.c
+*/
+class cr {
+    private $priv_member;
+    function cr($val) {
+        $this->priv_member = $val;
+    }
+    static function comp_func_cr($a, $b) {
+        if ($a->priv_member === $b->priv_member) return 0;
+        return ($a->priv_member > $b->priv_member) ? 1 : -1;
+    }
+    static function comp_func_key($a, $b) {
+        if ($a === $b) return 0;
+        return ($a > $b) ? 1 : -1;
+    }
+}
+$a = array("0.1" => new cr(9), "0.5" => new cr(12), 0 => new cr(23), 1 => new 
cr(4), 2 => new cr(-15),);
+$b = array("0.2" => new cr(9), "0.5" => new cr(22), 0 => new cr(3), 1 => new 
cr(4), 2 => new cr(-15),);
+$result = array_uintersect_uassoc($a, $b, array("cr", "comp_func_cr"), 
array("cr", "comp_func_key"));
+var_dump($result);
+?>
+--EXPECTF--
+array(2) {
+  [1]=>
+  object(cr)#%d (1) {
+    ["priv_member":"cr":private]=>
+    int(4)
+  }
+  [2]=>
+  object(cr)#%d (1) {
+    ["priv_member":"cr":private]=>
+    int(-15)
+  }
+}
+--UEXPECTF--
+array(2) {
+  [1]=>
+  object(cr)#%d (1) {
+    [u"priv_member":u"cr":private]=>
+    int(4)
+  }
+  [2]=>
+  object(cr)#%d (1) {
+    [u"priv_member":u"cr":private]=>
+    int(-15)
+  }
+}
\ No newline at end of file
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/array/array_diff_key_basic.phpt?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/standard/tests/array/array_diff_key_basic.phpt
diff -u /dev/null php-src/ext/standard/tests/array/array_diff_key_basic.phpt:1.2
--- /dev/null   Fri Jan 25 00:17:34 2008
+++ php-src/ext/standard/tests/array/array_diff_key_basic.phpt  Fri Jan 25 
00:17:34 2008
@@ -0,0 +1,26 @@
+--TEST--
+Test array_diff_key() : basic functionality 
+--FILE--
+<?php
+/*
+* proto array array_diff_key(array arr1, array arr2 [, array ...])
+* Function is implemented in ext/standard/array.c
+*/
+$array1 = array('blue' => 1, 'red' => 2, 'green' => 3, 'purple' => 4);
+$array2 = array('green' => 5, 'blue' => 6, 'yellow' => 7, 'cyan' => 8);
+var_dump(array_diff_key($array1, $array2));
+?>
+--EXPECT--
+array(2) {
+  ["red"]=>
+  int(2)
+  ["purple"]=>
+  int(4)
+}
+--UEXPECT--
+array(2) {
+  [u"red"]=>
+  int(2)
+  [u"purple"]=>
+  int(4)
+}
\ No newline at end of file

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to