Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
fpc-src / usr / share / fpcsrc / 3.0.0 / tests / test / tgeneric95.pp
Size: Mime:
program tgeneric95;

{$mode objfpc}

type
  generic TTest<T> = record
    f: T;
  end;

function Test(aArg: Integer): Integer;
type
  TTest_Word = specialize TTest<Word>;
var
  t: TTest_Word;
begin
  Result := SizeOf(t.f);
end;

function Test(aArg: String): Integer;
type
  TTest_String = specialize TTest<String>;
var
  t: TTest_String;
begin
  Result := SizeOf(t.f);
end;

procedure DoError(const aMessage: String);
begin
  Writeln(aMessage);
  ExitCode := 1;
  Halt;
end;

begin
  if Test(42) <> SizeOf(Word) then
    DoError('Unexpected size of field');
  if Test('Test') <> SizeOf(String) then
    DoError('Unexpe size of field');
end.