Return to str_rot13_basic.phpt CVS log | Up to [ELWIX - Embedded LightWeight unIX -] / embedaddon / php / ext / standard / tests / strings |
1.1 misho 1: --TEST-- 2: Test soundex() function : basic functionality 3: --FILE-- 4: <?php 5: /* Prototype : string str_rot13 ( string $str ) 6: * Description: Perform the rot13 transform on a string 7: * Source code: ext/standard/string.c 8: */ 9: echo "*** Testing str_rot13() : basic functionality ***\n"; 10: 11: echo "\nBasic tests\n"; 12: var_dump(str_rot13("str_rot13() tests starting")); 13: var_dump(str_rot13("abcdefghijklmnopqrstuvwxyz")); 14: 15: echo "\nEnsure numeric characters are left untouched\n"; 16: if (strcmp(str_rot13("0123456789"), "0123456789") == 0) { 17: echo "Strings equal : TEST PASSED\n"; 18: } else { 19: echo "Strings unequal : TEST FAILED\n"; 20: } 21: 22: echo "\nEnsure non-alphabetic characters are left untouched\n"; 23: if (strcmp(str_rot13("!%^&*()_-+={}[]:;@~#<,>.?"), "!%^&*()_-+={}[]:;@~#<,>.?")) { 24: echo "Strings equal : TEST PASSED\n"; 25: } else { 26: echo "Strings unequal : TEST FAILED\n"; 27: } 28: 29: echo "\nEnsure strings round trip\n"; 30: $str = "str_rot13() tests starting"; 31: $encode = str_rot13($str); 32: $decode = str_rot13($encode); 33: if (strcmp($str, $decode) == 0) { 34: echo "Strings equal : TEST PASSED\n"; 35: } else { 36: echo "Strings unequal : TEST FAILED\n"; 37: } 38: ?> 39: ===DONE=== 40: --EXPECTF-- 41: *** Testing str_rot13() : basic functionality *** 42: 43: Basic tests 44: string(26) "fge_ebg13() grfgf fgnegvat" 45: string(26) "nopqrstuvwxyzabcdefghijklm" 46: 47: Ensure numeric characters are left untouched 48: Strings equal : TEST PASSED 49: 50: Ensure non-alphabetic characters are left untouched 51: Strings unequal : TEST FAILED 52: 53: Ensure strings round trip 54: Strings equal : TEST PASSED 55: ===DONE===