gmp_accept_test.pas 1016 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. program gmp_accept_test;
  2. {$mode objfpc}{$H+}
  3. uses
  4. heaptrc, testutils, strutils, math, sysutils, gmp, classes;
  5. type
  6. TTestCase = class(TPersistent);
  7. TTestCases = class of TTestCase;
  8. {$include gmp_test_intf}
  9. {$include gmp_test_impl}
  10. procedure Run(Tests: array of TTestCases);
  11. var
  12. TestObj: TTestCase;
  13. MethodList: TStringList;
  14. TI, MI: integer;
  15. Test: procedure of object;
  16. begin
  17. for TI := 0 to Length(Tests) - 1 do begin
  18. TestObj := Tests[TI].Create;
  19. MethodList := TStringList.Create;
  20. try
  21. TMethod(Test).Data := TestObj;
  22. GetMethodList(TestObj, MethodList);
  23. for MI := 0 to MethodList.Count - 1 do begin
  24. TMethod(Test).Code := MethodList.Objects[MI];
  25. Test;
  26. end;
  27. WriteLn(Format('%s: Tests executed: %d.', [TestObj.ClassName, MethodList.Count]));
  28. finally
  29. MethodList.Free;
  30. TestObj.Free;
  31. end;
  32. end;
  33. end;
  34. begin
  35. HaltOnNotReleased := True; // exit code wanted
  36. Run([TTestGmpBinding, TTestGmpExtensions, TTestGmpOperators]);
  37. end.