tstring9.pp 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. program tstring9
  2. ;
  3. {$ifdef fpc}{$mode objfpc}{$h+}{$endif}
  4. uses
  5. jdk15;
  6. {$macro on}
  7. {$define write:=JLSystem.fout.print}
  8. {$define writeln:=JLSystem.fout.println}
  9. var
  10. a: array[0..0] of char = (#0);
  11. function test_pchar: boolean;
  12. var
  13. s: string;
  14. p: pchar;
  15. begin
  16. p := '';
  17. s := '1234567890';
  18. s := p;
  19. test_pchar := (s = '');
  20. if not test_pchar then writeln('test_pchar failed');
  21. end;
  22. function test_chararray: boolean;
  23. var
  24. s: string;
  25. begin
  26. s := '1234567890';
  27. s := a;
  28. test_chararray := (s = '');
  29. if not test_chararray then writeln('test_chararray failed');
  30. end;
  31. function test_pchar_to_widestr: boolean;
  32. var
  33. s: widestring;
  34. p: PChar;
  35. begin
  36. p := '';
  37. s := '1234567890';
  38. s := p; { win32: function result assign not optimized! }
  39. test_pchar_to_widestr := (s = '');
  40. if not test_pchar_to_widestr then writeln('test_pchar_to_widestr failed');
  41. end;
  42. function test_chararray_to_widestr: boolean;
  43. var
  44. s: widestring;
  45. begin
  46. s := '1234567890';
  47. s := a;
  48. test_chararray_to_widestr := (s = '');
  49. if not test_chararray_to_widestr then writeln('test_chararray_to_widestr failed');
  50. end;
  51. begin
  52. if not test_pchar then Halt(1);
  53. if not test_chararray then Halt(2);
  54. if not test_pchar_to_widestr then Halt(3);
  55. if not test_chararray_to_widestr then Halt(4);
  56. end.