Sophie

Sophie

distrib > Mageia > 7 > i586 > by-pkgid > 6ff261dcf0789896ddf26c61e38f88e3 > files > 136

fpc-doc-3.0.4-6.mga7.i586.rpm

program gmp_accept_test;

{$mode objfpc}{$H+}

uses
  heaptrc, testutils, strutils, math, sysutils, gmp, classes;


type
  TTestCase = class(TPersistent);
  TTestCases = class of TTestCase;

{$include gmp_test_intf}
{$include gmp_test_impl}

procedure Run(Tests: array of TTestCases);
var
  TestObj: TTestCase;
  MethodList: TStringList;
  TI, MI: integer;
  Test: procedure of object;
begin
  for TI := 0 to Length(Tests) - 1 do begin
    TestObj := Tests[TI].Create;
    MethodList := TStringList.Create;
    try
      TMethod(Test).Data := TestObj;
      GetMethodList(TestObj, MethodList);
      for MI := 0 to MethodList.Count - 1 do begin
        TMethod(Test).Code := MethodList.Objects[MI];
        Test;
      end;
      WriteLn(Format('%s: Tests executed: %d.', [TestObj.ClassName, MethodList.Count]));
    finally
      MethodList.Free;
      TestObj.Free;
    end;
  end;
end;

begin
  HaltOnNotReleased := True; // exit code wanted
  Run([TTestGmpBinding, TTestGmpExtensions, TTestGmpOperators]);
end.