From b97c8bdf5594ac273f9f3851030b694b97789035 Mon Sep 17 00:00:00 2001 From: Jonas Maebe Date: Sat, 12 Feb 2022 15:25:19 +0100 Subject: [PATCH] testobj3: fix test Use RTL StringRefCount instead of local GetRefCount that only supports some platforms and depends on the internal layout of ansistring headers --- tests/test/units/objects/testobj3.pp | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/tests/test/units/objects/testobj3.pp b/tests/test/units/objects/testobj3.pp index c34a9dfa11..2719b00b85 100644 --- a/tests/test/units/objects/testobj3.pp +++ b/tests/test/units/objects/testobj3.pp @@ -2,11 +2,6 @@ program testobj3; uses Objects; -function GetRefCount(const S: RawByteString): SizeInt; -begin - GetRefCount:=PSizeInt(PByte(S)-2*SizeOf(SizeInt))^; -end; - procedure Error(ErrNo: Integer); begin Writeln('Error! ', ErrNo); @@ -25,21 +20,22 @@ begin S[3] := 'l'; S[4] := 'l'; S[5] := 'o'; - if GetRefCount(S)<>1 then + writeln(stringrefcount(s)); + if stringrefcount(S)<>1 then Error(1); coll := New(PRawByteStringCollection, Init(100, 100)); coll^.AtInsert(0, S); - if GetRefCount(S)<>2 then + if stringrefcount(S)<>2 then Error(2); S2 := RawByteString(coll^.At(0)); - if GetRefCount(S)<>3 then + if stringrefcount(S)<>3 then Error(3); if S2<>'Hello' then Error(4); if RawByteString(coll^.At(0))<>'Hello' then Error(5); Dispose(coll, Done); - if GetRefCount(S)<>2 then + if stringrefcount(S)<>2 then Error(6); end;