Przeglądaj źródła

Merged revisions 11149 via svnmerge from
svn+ssh://[email protected]/FPC/svn/fpc/trunk

........
r11149 | jonas | 2008-06-01 00:10:53 +0200 (Sun, 01 Jun 2008) | 6 lines

* fixed tbinaryobjectwrite.writeset/readset on big endian systems
(and made it future proof in case the set format should change
again, as long as the size of all streamed sets is guaranteed
to be 4 bytes and if their packset setting is guaranteed to
be 0).

........

git-svn-id: branches/fixes_2_2@11159 -

Jonas Maebe 17 lat temu
rodzic
commit
a62ade66d0
2 zmienionych plików z 54 dodań i 0 usunięć
  1. 1 0
      .gitattributes
  2. 53 0
      tests/test/units/classes/tsetstream.pp

+ 1 - 0
.gitattributes

@@ -7486,6 +7486,7 @@ tests/test/uinline4b.pp svneol=native#text/plain
 tests/test/umacpas1.pp svneol=native#text/plain
 tests/test/umainnam.pp svneol=native#text/plain
 tests/test/units/classes/tmakeobjinst.pp svneol=native#text/plain
+tests/test/units/classes/tsetstream.pp svneol=native#text/plain
 tests/test/units/crt/tcrt.pp svneol=native#text/plain
 tests/test/units/crt/tctrlc.pp svneol=native#text/plain
 tests/test/units/dos/hello.pp svneol=native#text/plain

+ 53 - 0
tests/test/units/classes/tsetstream.pp

@@ -0,0 +1,53 @@
+program storedfalse;
+{$ifdef FPC}{$mode objfpc}{$h+}{$INTERFACES CORBA}{$endif}
+{$ifdef mswindows}{$apptype console}{$endif}
+uses
+ {$ifdef FPC}{$ifdef linux}cthreads,{$endif}{$endif}
+ sysutils,classes;
+
+type
+ tenum = (eena,eenb,eenc,eend,eene,eenf,eeng,eenh,eeni);
+ tset = set of tenum;
+
+ ttestclass1 = class(tcomponent)
+  private
+   fprop1: tset;
+  public
+   property prop1: tset read fprop1 write fprop1 stored true;
+ end;
+
+ ttestclass2 = class(ttestclass1)
+  published
+   property prop1;
+ end;
+
+var
+ testclass2,testclass3: ttestclass2;
+ stream1,stream2: tmemorystream;
+ str1: ansistring;
+begin
+ testclass2:= ttestclass2.create(nil);
+ testclass2.prop1:= [eenb,eend,eene,eenh,eeni];
+ stream1:= tmemorystream.create;
+ try
+  stream1.writecomponent(testclass2);
+  stream2:= tmemorystream.create;
+  try
+   stream1.position:= 0;
+   objectbinarytotext(stream1,stream2);
+   stream1.position:= 0;
+   stream2.position:= 0;
+   setlength(str1,stream2.size);
+   move(stream2.memory^,str1[1],length(str1));
+   writeln(str1);
+   testclass3:=ttestclass2.create(nil);
+   stream1.readcomponent(testclass3);
+   if (testclass3.prop1<>[eenb,eend,eene,eenh,eeni]) then
+     halt(1);
+  finally
+   stream2.free;
+  end;
+ finally
+  stream1.free;
+ end;
+end.