Return to strncmp_variation1.phpt CVS log | Up to [ELWIX - Embedded LightWeight unIX -] / embedaddon / php / ext / standard / tests / strings |
1.1 misho 1: --TEST-- 2: Test strncmp() function: usage variations - case-sensitivity 3: --FILE-- 4: <?php 5: /* Prototype : int strncmp ( string $str1, string $str2, int $len ); 6: * Description: Binary safe case-sensitive string comparison of the first n characters 7: * Source code: Zend/zend_builtin_functions.c 8: */ 9: 10: /* Test strncmp() function with upper-case and lower-case alphabets as inputs for 'str1' and 'str2' */ 11: 12: echo "*** Test strncmp() function: with alphabets ***\n"; 13: echo "-- Passing upper-case letters for 'str1' --\n"; 14: for($ASCII = 65; $ASCII <= 90; $ASCII++) { 15: var_dump( strncmp( chr($ASCII), chr($ASCII), 1 ) ); //comparing uppercase letters with uppercase letters; exp: int(0) 16: var_dump( strncmp( chr($ASCII), chr($ASCII + 32), 1 ) ); //comparing uppercase letters with lowercase letters; exp: value < 0 17: } 18: 19: echo "\n-- Passing lower-case letters for 'str1' --\n"; 20: for($ASCII = 97; $ASCII <= 122; $ASCII++) { 21: var_dump( strncmp( chr($ASCII), chr($ASCII), 1 ) ); //comparing lowercase letters with lowercase letters; exp: int(0) 22: var_dump( strncmp( chr($ASCII), chr($ASCII - 32), 1 ) ); //comparing lowercase letters with uppercase letters; exp: value > 0 23: } 24: echo "*** Done ***"; 25: ?> 26: --EXPECTREGEX-- 27: \*\*\* Test strncmp\(\) function: with alphabets \*\*\* 28: -- Passing upper-case letters for 'str1' -- 29: int\(0\) 30: int\(-[1-9][0-9]*\) 31: int\(0\) 32: int\(-[1-9][0-9]*\) 33: int\(0\) 34: int\(-[1-9][0-9]*\) 35: int\(0\) 36: int\(-[1-9][0-9]*\) 37: int\(0\) 38: int\(-[1-9][0-9]*\) 39: int\(0\) 40: int\(-[1-9][0-9]*\) 41: int\(0\) 42: int\(-[1-9][0-9]*\) 43: int\(0\) 44: int\(-[1-9][0-9]*\) 45: int\(0\) 46: int\(-[1-9][0-9]*\) 47: int\(0\) 48: int\(-[1-9][0-9]*\) 49: int\(0\) 50: int\(-[1-9][0-9]*\) 51: int\(0\) 52: int\(-[1-9][0-9]*\) 53: int\(0\) 54: int\(-[1-9][0-9]*\) 55: int\(0\) 56: int\(-[1-9][0-9]*\) 57: int\(0\) 58: int\(-[1-9][0-9]*\) 59: int\(0\) 60: int\(-[1-9][0-9]*\) 61: int\(0\) 62: int\(-[1-9][0-9]*\) 63: int\(0\) 64: int\(-[1-9][0-9]*\) 65: int\(0\) 66: int\(-[1-9][0-9]*\) 67: int\(0\) 68: int\(-[1-9][0-9]*\) 69: int\(0\) 70: int\(-[1-9][0-9]*\) 71: int\(0\) 72: int\(-[1-9][0-9]*\) 73: int\(0\) 74: int\(-[1-9][0-9]*\) 75: int\(0\) 76: int\(-[1-9][0-9]*\) 77: int\(0\) 78: int\(-[1-9][0-9]*\) 79: int\(0\) 80: int\(-[1-9][0-9]*\) 81: 82: -- Passing lower-case letters for 'str1' -- 83: int\(0\) 84: int\([1-9][0-9]*\) 85: int\(0\) 86: int\([1-9][0-9]*\) 87: int\(0\) 88: int\([1-9][0-9]*\) 89: int\(0\) 90: int\([1-9][0-9]*\) 91: int\(0\) 92: int\([1-9][0-9]*\) 93: int\(0\) 94: int\([1-9][0-9]*\) 95: int\(0\) 96: int\([1-9][0-9]*\) 97: int\(0\) 98: int\([1-9][0-9]*\) 99: int\(0\) 100: int\([1-9][0-9]*\) 101: int\(0\) 102: int\([1-9][0-9]*\) 103: int\(0\) 104: int\([1-9][0-9]*\) 105: int\(0\) 106: int\([1-9][0-9]*\) 107: int\(0\) 108: int\([1-9][0-9]*\) 109: int\(0\) 110: int\([1-9][0-9]*\) 111: int\(0\) 112: int\([1-9][0-9]*\) 113: int\(0\) 114: int\([1-9][0-9]*\) 115: int\(0\) 116: int\([1-9][0-9]*\) 117: int\(0\) 118: int\([1-9][0-9]*\) 119: int\(0\) 120: int\([1-9][0-9]*\) 121: int\(0\) 122: int\([1-9][0-9]*\) 123: int\(0\) 124: int\([1-9][0-9]*\) 125: int\(0\) 126: int\([1-9][0-9]*\) 127: int\(0\) 128: int\([1-9][0-9]*\) 129: int\(0\) 130: int\([1-9][0-9]*\) 131: int\(0\) 132: int\([1-9][0-9]*\) 133: int\(0\) 134: int\([1-9][0-9]*\) 135: \*\*\* Done \*\*\*