You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

33 lines
750 B

  1. --TEST--
  2. sqlite: UDF binary handling functions
  3. --SKIPIF--
  4. <?php # vim:ft=php
  5. if (!extension_loaded("sqlite")) print "skip"; ?>
  6. --FILE--
  7. <?php
  8. $data = array(
  9. "hello there",
  10. "this has a \x00 char in the middle",
  11. "\x01 this has an 0x01 at the start",
  12. "this has \x01 in the middle"
  13. );
  14. foreach ($data as $item) {
  15. $coded = sqlite_udf_encode_binary($item);
  16. echo bin2hex($coded) . "\n";
  17. $decoded = sqlite_udf_decode_binary($coded);
  18. if ($item != $decoded) {
  19. echo "FAIL! $item decoded is $decoded\n";
  20. }
  21. }
  22. echo "OK!\n";
  23. ?>
  24. --EXPECT--
  25. 68656c6c6f207468657265
  26. 0101736768721f6760721f601fff1f626760711f686d1f7367641f6c6863636b64
  27. 0102ff1e726667711e665f711e5f6c1e2e762e2f1e5f721e7266631e71725f7072
  28. 7468697320686173200120696e20746865206d6964646c65
  29. OK!