str_rot13_basic.phpt 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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. echo "\nBasic tests\n";
  11. var_dump(str_rot13("str_rot13() tests starting"));
  12. var_dump(str_rot13("abcdefghijklmnopqrstuvwxyz"));
  13. echo "\nEnsure numeric characters are left untouched\n";
  14. if (strcmp(str_rot13("0123456789"), "0123456789") == 0) {
  15. echo "Strings equal : TEST PASSED\n";
  16. } else {
  17. echo "Strings unequal : TEST FAILED\n";
  18. }
  19. echo "\nEnsure non-alphabetic characters are left untouched\n";
  20. if (strcmp(str_rot13("!%^&*()_-+={}[]:;@~#<,>.?"), "!%^&*()_-+={}[]:;@~#<,>.?")) {
  21. echo "Strings equal : TEST PASSED\n";
  22. } else {
  23. echo "Strings unequal : TEST FAILED\n";
  24. }
  25. echo "\nEnsure strings round trip\n";
  26. $str = "str_rot13() tests starting";
  27. $encode = str_rot13($str);
  28. $decode = str_rot13($encode);
  29. if (strcmp($str, $decode) == 0) {
  30. echo "Strings equal : TEST PASSED\n";
  31. } else {
  32. echo "Strings unequal : TEST FAILED\n";
  33. }
  34. ?>
  35. ===DONE===
  36. --EXPECTF--
  37. *** Testing str_rot13() : basic functionality ***
  38. Basic tests
  39. string(26) "fge_ebg13() grfgf fgnegvat"
  40. string(26) "nopqrstuvwxyzabcdefghijklm"
  41. Ensure numeric characters are left untouched
  42. Strings equal : TEST PASSED
  43. Ensure non-alphabetic characters are left untouched
  44. Strings unequal : TEST FAILED
  45. Ensure strings round trip
  46. Strings equal : TEST PASSED
  47. ===DONE===