2
0

tstring9.pp 1.2 KB

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