Browse Source

merge r17608 from cpstrnew branch by inoussa:
tests

git-svn-id: trunk@19125 -

paul 14 years ago
parent
commit
23ea810e0c
3 changed files with 88 additions and 0 deletions
  1. 2 0
      .gitattributes
  2. 47 0
      tests/test/tcpstransistr2widechararray.pp
  3. 39 0
      tests/test/tcpstransistrcopy.pp

+ 2 - 0
.gitattributes

@@ -9947,8 +9947,10 @@ tests/test/tcpstr6.pp svneol=native#text/plain
 tests/test/tcpstr7.pp svneol=native#text/plain
 tests/test/tcpstr8.pp svneol=native#text/pascal
 tests/test/tcpstransistr2shortstring.pp svneol=native#text/plain
+tests/test/tcpstransistr2widechararray.pp svneol=native#text/plain
 tests/test/tcpstransistrcompare.pp svneol=native#text/plain
 tests/test/tcpstransistrcompareequal.pp svneol=native#text/plain
+tests/test/tcpstransistrcopy.pp svneol=native#text/plain
 tests/test/tcpstrassignansistr.pp svneol=native#text/plain
 tests/test/tcpstrchar2ansistr.pp svneol=native#text/plain
 tests/test/tcpstrconcat.pp svneol=native#text/plain

+ 47 - 0
tests/test/tcpstransistr2widechararray.pp

@@ -0,0 +1,47 @@
+uses
+{$ifdef unix}
+  cwstring,
+{$endif unix}
+  sysutils;
+  
+type  
+  ts850 = type string<850>;
+
+  procedure doerror(ANumber : Integer);
+  begin
+    WriteLn('error ',ANumber);
+    Halt(ANumber);
+  end;
+
+var
+  x : ts850;
+  i : Integer;
+  sa : ansistring;
+  ua : array[0..7] of UnicodeChar;
+  uc : UnicodeChar;
+  us : UnicodeString;
+begin
+  sa := 'abc'#$00A9#$00AE'123';
+  ua := sa;
+  for i := 1 to Length(sa) do
+    begin
+      uc := sa[i];
+      if (uc <> ua[i-1]) then begin
+        writeln(i);
+        doerror(1);
+      end;
+    end;
+  x := 'abc'#$00A9#$00AE'123';
+  ua := x;
+  us := x;
+  for i := 1 to Length(sa) do
+    begin
+      uc := us[i];
+      if (uc <> ua[i-1]) then begin
+        writeln(i);
+        doerror(2);
+      end;
+    end;
+
+  WriteLn('Ok');
+end.

+ 39 - 0
tests/test/tcpstransistrcopy.pp

@@ -0,0 +1,39 @@
+uses
+{$ifdef unix}
+  cwstring,
+{$endif unix}
+  sysutils;
+  
+type  
+  ts850 = type string<850>;
+  ts1252 = type string<1252>;
+
+  procedure doerror(ANumber : Integer);
+  begin
+    WriteLn('error ',ANumber);
+    Halt(ANumber);
+  end;
+
+var
+  x, y, z : ts850;
+  i : Integer;
+  c : Integer;
+  sa : ansistring;
+begin
+  sa := 'abc'#$00A9#$00AE'123';
+  x := Copy(sa,1,2);
+  if (StringCodePage(x) <> 850) then
+    doerror(1);
+  if (Length(x) <> 2) then
+    doerror(2);
+  x := Copy(sa,2,3);
+  y := 'abc'#$00A9#$00AE'123';
+  z := Copy(y,2,3);
+  for i := 1 to Length(x) do
+    begin
+      if (Byte(x[i]) <> Byte(y[i+1])) then
+        doerror(3);
+    end;
+
+  WriteLn('Ok');
+end.