2
0

tunistr4.pp 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. 
  2. {$ifdef fpc}
  3. {$mode objfpc}
  4. {$endif fpc}
  5. uses
  6. {$ifdef unix}
  7. cthreads, cwstring,
  8. {$endif}
  9. Classes, SysUtils;
  10. type
  11. tc = class(tthread)
  12. orgstr: ansistring;
  13. cnvstr: unicodestring;
  14. constructor create(const s: ansistring; const w: unicodestring);
  15. procedure execute; override;
  16. end;
  17. const
  18. // string with an invalid utf-8 code sequence
  19. str1 = #$c1#$34'Życie'#$c1#$34' jest jak papier '#$c1#$34'toaletowy'#$c1#$34' : długie, szare i '#$c1#$34'do'#$c1#$34' dupy';
  20. str2 = 'Życie '#$c1#$34'jest'#$c1#$34' jak papier toaletowy : '#$c1#$34'długie'#$c1#$34', szare i do '#$c1#$34'dupy'#$c1#$34'222222222222222222222222222222222222222222222222';
  21. str3 = 'Życie jest '#$c1#$34'jak'#$c1#$34' papier 333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333 toaletowy : długie, '#$c1#$34'szare'#$c1#$34' i do dupy';
  22. str4 = 'Życie jest 4444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444 jak '#$c1#$34'papier'#$c1#$34' toaletowy : długie, szare '#$c1#$34'i'#$c1#$34' do dupy';
  23. count = 20000;
  24. var
  25. wstr: unicodestring;
  26. // cnvstr: ansistring;
  27. error: boolean;
  28. constructor tc.create(const s: ansistring; const w: unicodestring);
  29. begin
  30. orgstr:=s;
  31. cnvstr:=w;
  32. inherited create(true);
  33. end;
  34. procedure tc.execute;
  35. var
  36. i: longint;
  37. w: unicodestring;
  38. begin
  39. for i := 1 to count do
  40. begin
  41. w:=orgstr;
  42. if (w<>cnvstr) then
  43. error:=true;
  44. end;
  45. end;
  46. var
  47. a: array[1..4] of tc;
  48. w1,w2,w3,w4: unicodestring;
  49. cnvstr: ansistring;
  50. begin
  51. error:=false;
  52. cnvstr:=str1;
  53. w1:=cnvstr;
  54. cnvstr:=str2;
  55. w2:=cnvstr;
  56. cnvstr:=str3;
  57. w3:=cnvstr;
  58. cnvstr:=str4;
  59. w4:=cnvstr;
  60. writeln(w1);
  61. writeln(w2);
  62. writeln(w3);
  63. writeln(w4);
  64. a[1]:=tc.create(str1,w1);
  65. a[2]:=tc.create(str2,w2);
  66. a[3]:=tc.create(str3,w3);
  67. a[4]:=tc.create(str4,w4);
  68. a[1].resume;
  69. a[2].resume;
  70. a[3].resume;
  71. a[4].resume;
  72. a[1].waitfor;
  73. a[2].waitfor;
  74. a[3].waitfor;
  75. a[4].waitfor;
  76. a[1].free;
  77. a[2].free;
  78. a[3].free;
  79. a[4].free;
  80. if error then
  81. halt(1);
  82. end.