testversion.pas 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. program testversion;
  2. {
  3. Test version macros/functions of SDL2 system.
  4. This file is part of
  5. SDL2-for-Pascal
  6. Copyright (C) 2020-2022 PGD Community
  7. Visit: https://github.com/PascalGameDevelopment/SDL2-for-Pascal
  8. }
  9. {$I testsettings.inc}
  10. uses
  11. Classes, SysUtils, SDL2;
  12. type
  13. ESDL2Error = class(Exception);
  14. var
  15. CompiledVersion: TSDL_Version = (major: 0; minor: 0; patch: 0);
  16. LinkedVersion: TSDL_Version = (major: 0; minor: 0; patch: 0);
  17. VersionNum: Cardinal = 0;
  18. begin
  19. write('Start SDL2 version test... ');
  20. try
  21. VersionNum := SDL_VERSIONNUM(1,2,3);
  22. if (VersionNum <> 1203) then
  23. raise ESDL2Error.Create('SDL_VERSIONNUM failed: 1203 expected, found: ' + IntToStr(VersionNum));
  24. SDL_VERSION(CompiledVersion);
  25. if (SDL_COMPILEDVERSION <> SDL_VERSIONNUM(CompiledVersion.major, CompiledVersion.minor, CompiledVersion.patch)) then
  26. raise ESDL2Error.Create('SDL_VERSION or SDL_COMPILEDVERSION failed: Version results do not match!');
  27. if not SDL_VERSION_ATLEAST(2,0,0) then
  28. raise ESDL2Error.Create('SDL_VERSION_ATLEAST failed: Version at least 2.0.0 should be true!');
  29. if SDL_VERSION_ATLEAST(3,0,0) then
  30. raise ESDL2Error.Create('SDL_VERSION_ATLEAST failed: Version at least 3.0.0 should be false!');
  31. SDL_GetVersion(@LinkedVersion);
  32. if @LinkedVersion = nil then
  33. raise ESDL2Error.Create('SDL_GetVersion failed: ' + SDL_GetError());
  34. if SDL_VERSIONNUM(LinkedVersion.major, LinkedVersion.minor, LinkedVersion.patch) = 0 then
  35. raise ESDL2Error.Create('SDL_GetVersion failed: Returns 0.0.0 .');
  36. except
  37. end;
  38. writeln('finished.');
  39. end.