Browse Source

merge r17486 from cpstrnew branch by michael:
* New tests from Inoussa to test various code-page string related issues

git-svn-id: trunk@19115 -

paul 14 years ago
parent
commit
6f08c86eb1

+ 6 - 0
.gitattributes

@@ -9946,6 +9946,12 @@ tests/test/tcpstr5.pp svneol=native#text/plain
 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/tcpstransistrcompare.pp svneol=native#text/plain
+tests/test/tcpstransistrcompareequal.pp svneol=native#text/plain
+tests/test/tcpstrconcatmulti.pp svneol=native#text/plain
+tests/test/tcpstrconcatmulti2.pp svneol=native#text/plain
+tests/test/tcpstrsetlength.pp svneol=native#text/plain
+tests/test/tcpstrsetlength2.pp svneol=native#text/plain
 tests/test/tcptypedconst.pp svneol=native#text/plain
 tests/test/tcptypedconst2.pp svneol=native#text/plain
 tests/test/tcptypedconst3.pp svneol=native#text/plain

+ 30 - 0
tests/test/tcpstransistrcompare.pp

@@ -0,0 +1,30 @@
+uses
+{$ifdef unix}
+  cwstring,
+{$endif unix}
+  SysUtils;
+  
+type
+  ts850 = type string<850>;
+  ts1251 = type string<1251>;  
+var
+  a850:ts850;
+  a1251 : ts1251;  
+  au : utf8string;
+begin 
+  au := #$00AE#$00A7;
+  a850 := au; 
+  a1251 := au;
+  if (a850>a1251) then
+    halt(1);
+  if (a850<a1251) then
+    halt(2);
+    
+  a850 := a850 + 'a'; 
+  if (a850<=a1251) then
+    halt(3);
+  if (a1251>=a850) then
+    halt(4);
+  
+  writeln('ok');
+end.

+ 21 - 0
tests/test/tcpstransistrcompareequal.pp

@@ -0,0 +1,21 @@
+uses
+{$ifdef unix}
+  cwstring,
+{$endif unix}
+  SysUtils;
+  
+type
+  ts850 = type string<850>;
+  ts1251 = type string<1251>;  
+var
+  a850:ts850;
+  a1251 : ts1251;  
+  au : utf8string;
+begin 
+  au := #$00AE#$00A7;
+  a850 := au; 
+  a1251 := au;
+  if (a850<>a1251) then
+    halt(1);
+  writeln('ok');
+end.

+ 37 - 0
tests/test/tcpstrconcatmulti.pp

@@ -0,0 +1,37 @@
+{$APPTYPE CONSOLE}
+// test "fpc_AnsiStr_Concat_multi" with a same type(same encoding) 
+uses
+{$ifdef unix}
+  cwstring,
+{$endif unix}
+  SysUtils;
+
+type
+  ts866 = type string<866>;
+var
+  a, b, c, d : ts866;
+begin
+  a := 'al';
+  b := 'b2';
+  c := 'c3';
+  
+  //without "DestS" in the array
+  d := a + b + c; 
+  if (StringCodePage(d) <> 866) then
+    halt(1);
+  //with empty "DestS" in the array
+  d := '';
+  d := d + a + b + c; 
+  if (StringCodePage(d) <> 866) then
+    halt(2);
+  //with "DestS" in the array at the start
+  d := d + b + c; 
+  if (StringCodePage(d) <> 866) then
+    halt(3);
+  //with "DestS" in the array, not at the start 
+  d := a + b + d + c; 
+  if (StringCodePage(d) <> 866) then
+    halt(4);
+  
+  WriteLn('ok');
+end.

+ 41 - 0
tests/test/tcpstrconcatmulti2.pp

@@ -0,0 +1,41 @@
+{$APPTYPE CONSOLE}
+// test "fpc_AnsiStr_Concat_multi" with a differant types(encodings) 
+uses
+{$ifdef unix}
+  cwstring,
+{$endif unix}
+  SysUtils;
+
+type
+  ts866 = type string<866>;
+  ts850 = type string<850>;
+  ts1251 = type string<1251>;
+var
+  a : ts1251;
+  b : ts850; 
+  c, d : ts866;
+begin
+  a := 'al';
+  b := 'b2';
+  c := 'c3';
+  
+  //without "DestS" in the array
+  d := a + b + c; 
+  if (StringCodePage(d) <> 866) then
+    halt(1);
+  //with empty "DestS" in the array
+  d := '';
+  d := d + a + b + c; 
+  if (StringCodePage(d) <> 866) then
+    halt(2);
+  //with "DestS" in the array at the start
+  d := d + a + b + c; 
+  if (StringCodePage(d) <> 866) then
+    halt(3);
+  //with "DestS" in the array, not at the start 
+  d := a + b + d + c; 
+  if (StringCodePage(d) <> 866) then
+    halt(4);
+    
+  WriteLn('ok');
+end.

+ 17 - 0
tests/test/tcpstrsetlength.pp

@@ -0,0 +1,17 @@
+uses
+{$ifdef unix}
+  cwstring,
+{$endif unix}
+  SysUtils;
+
+type
+  ts866 = type string<866>;
+var
+  a866 : ts866;
+begin
+  a866 := '';
+  SetLength(a866,10);
+  if (StringCodePage(a866) <> 866) then
+    halt(1);
+  WriteLn('ok');
+end.

+ 17 - 0
tests/test/tcpstrsetlength2.pp

@@ -0,0 +1,17 @@
+uses
+{$ifdef unix}
+  cwstring,
+{$endif unix}
+  SysUtils;
+
+type
+  ts866 = type string<866>;
+var
+  a866 : ts866;
+begin
+  a866 := '123';
+  SetLength(a866,10);
+  if (StringCodePage(a866) <> 866) then
+    halt(1);
+  WriteLn('ok');
+end.