imap_base64_basic.phpt 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. --TEST--
  2. Test imap_base64() function : basic functionality
  3. --SKIPIF--
  4. <?php
  5. extension_loaded('imap') or die('skip imap extension not available in this build');
  6. ?>
  7. --FILE--
  8. <?php
  9. /* Prototype : string imap_base64 ( string $text )
  10. * Description: Decode BASE64 encoded text.
  11. * Source code: ext/imap/php_imap.c
  12. */
  13. echo "*** Testing imap_base64() : basic functionality ***\n";
  14. $str = b'This is an example string to be base 64 encoded';
  15. $base64 = base64_encode($str);
  16. if (imap_base64($base64) == $str) {
  17. echo "TEST PASSED\n";
  18. } else {
  19. echo "TEST FAILED";
  20. }
  21. $str = b'!£$%^&*()_+-={][];;@~#?/>.<,';
  22. $base64 = base64_encode($str);
  23. if (imap_base64($base64) == $str) {
  24. echo "TEST PASSED\n";
  25. } else {
  26. echo "TEST FAILED";
  27. }
  28. $hex = b'x00\x01\x02\x03\x04\x05\x06\xFA\xFB\xFC\xFD\xFE\xFF';
  29. $base64 = base64_encode($hex);
  30. if (imap_base64($base64) == $hex) {
  31. echo "TEST PASSED\n";
  32. } else {
  33. echo "TEST FAILED";
  34. }
  35. ?>
  36. ===Done===
  37. --EXPECT--
  38. *** Testing imap_base64() : basic functionality ***
  39. TEST PASSED
  40. TEST PASSED
  41. TEST PASSED
  42. ===Done===