summaryrefslogtreecommitdiff
path: root/fpcsrc/tests/webtbs/tw10791.pp
blob: 4c2b69ea4ca2774d6945d046b569bda89607e177 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
{$ifdef FPC}{$mode objfpc}{$h+}{$endif}
{$ifdef mswindows}{$apptype console}{$endif}
uses
 sysutils,classes;
type
 ttestclass = class(tcomponent)
  private
   frealprop: real;
  published
   property realprop: real read frealprop write frealprop;
 end;
var
 instance1,instance2: ttestclass;
 stream1,stream2: tmemorystream;
begin
 instance1:= ttestclass.create(nil);
 instance2:= ttestclass.create(nil);
 stream1:= tmemorystream.create;
 stream2:= tmemorystream.create;
 try
  instance1.realprop:= 1e10;
  stream1.writecomponent(instance1);
  stream1.position:= 0;
  objectbinarytotext(stream1,stream2);
  stream2.position:= 0;
  stream1.clear;
  objecttexttobinary(stream2,stream1);
  stream1.position:= 0;
  stream1.readcomponent(instance2);
  writeln('instance1: ',instance1.realprop,' instance2: ',instance2.realprop);
  if instance1.realprop<>instance2.realprop then
    halt(1);

  stream1.clear;
  stream2.clear;
  instance1.realprop:= 1;
  stream1.writecomponent(instance1);
  stream1.position:= 0;
  objectbinarytotext(stream1,stream2);
  stream2.position:= 0;
  stream1.clear;
  objecttexttobinary(stream2,stream1);
  stream1.position:= 0;
  stream1.readcomponent(instance2);
  writeln('instance1: ',instance1.realprop,' instance2: ',instance2.realprop);
  if instance1.realprop<>instance2.realprop then
    halt(1);
finally
  instance1.free;
  instance2.free;
  stream1.free;
  stream2.free;
 end;
end.