PageRenderTime 43ms CodeModel.GetById 19ms RepoModel.GetById 0ms app.codeStats 0ms

/trunk/Examples/test-suite/php/primitive_ref_runme.php

#
PHP | 34 lines | 26 code | 6 blank | 2 comment | 2 complexity | a2053359c46972772dcc5cfdb362785c MD5 | raw file
Possible License(s): LGPL-2.1, Cube, GPL-3.0, 0BSD, GPL-2.0
  1. <?php
  2. require "tests.php";
  3. require "primitive_ref.php";
  4. # A large long long number is too big, so PHP makes treats it as a double, but SWIG opts to return it as a string.
  5. # The conversion to double can lose precision so this isn't an exact comparison.
  6. function long_long_equal($a,$b,$message) {
  7. if (! ($a===$b))
  8. if (! ((double)$a===$b))
  9. return check::fail($message . ": '$a'!=='$b'");
  10. return TRUE;
  11. }
  12. check::equal(ref_over(3), 3, "ref_over failed");
  13. check::equal(ref_int(3), 3, "ref_int failed");
  14. check::equal(ref_uint(3), 3, "ref_uint failed");
  15. check::equal(ref_short(3), 3, "ref_short failed");
  16. check::equal(ref_ushort(3), 3, "ref_ushort failed");
  17. check::equal(ref_long(3), 3, "ref_long failed");
  18. check::equal(ref_ulong(3), 3, "ref_ulong failed");
  19. check::equal(ref_schar(3), 3, "ref_schar failed");
  20. check::equal(ref_uchar(3), 3, "ref_uchar failed");
  21. check::equal(ref_bool(true), true, "ref_bool failed");
  22. check::equal(ref_float(3.5), 3.5, "ref_float failed");
  23. check::equal(ref_double(3.5), 3.5, "ref_double failed");
  24. check::equal(ref_char('x'), 'x', "ref_char failed");
  25. long_long_equal(ref_longlong(0x123456789ABCDEF0), 0x123456789ABCDEF0, "ref_longlong failed");
  26. long_long_equal(ref_ulonglong(0xF23456789ABCDEF0), 0xF23456789ABCDEF0, "ref_ulonglong failed");
  27. check::done();
  28. ?>