diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 742798ac..69f38af1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -61,6 +61,15 @@ jobs: - name: Test 1 - Run Init Test run: | ./tests/testinit + - name: Test 2 - Compile Version Test + uses: suve/GHActions-FPC@v0.3.2 + with: + source: tests/testversion.pas + flags: Fl/usr/local/lib + verbosity: ewnh + - name: Test 2 - Run Version Test + run: | + ./tests/testversion ubuntu-20-04: runs-on: ubuntu-20.04 steps: @@ -113,6 +122,14 @@ jobs: mkdir ~/tmp export XDG_RUNTIME_DIR=~/tmp ./tests/testinit + - name: Test 2 - Compile Version Test + uses: suve/GHActions-FPC@v0.3.2 + with: + source: tests/testversion.pas + verbosity: ewnh + - name: Test 2 - Run Version Test + run: | + ./tests/testversion windows-2022: runs-on: windows-2022 steps: diff --git a/tests/testversion.pas b/tests/testversion.pas new file mode 100644 index 00000000..5526b28c --- /dev/null +++ b/tests/testversion.pas @@ -0,0 +1,56 @@ +program testversion; + +{ + + Test version macros/functions of SDL2 system. + + This file is part of + + SDL2-for-Pascal + Copyright (C) 2020-2022 PGD Community + Visit: https://github.com/PascalGameDevelopment/SDL2-for-Pascal + +} + +{$I testsettings.inc} + +uses + Classes, SysUtils, SDL2; + +type + ESDL2Error = class(Exception); + +var + CompiledVersion: TSDL_Version = (major: 0; minor: 0; patch: 0); + LinkedVersion: TSDL_Version = (major: 0; minor: 0; patch: 0); + VersionNum: Cardinal = 0; +begin + write('Start SDL2 version test... '); + + try + VersionNum := SDL_VERSIONNUM(1,2,3); + if (VersionNum <> 1203) then + raise ESDL2Error.Create('SDL_VERSIONNUM failed: 1203 expected, found: ' + IntToStr(VersionNum)); + + SDL_VERSION(CompiledVersion); + if (SDL_COMPILEDVERSION <> SDL_VERSIONNUM(CompiledVersion.major, CompiledVersion.minor, CompiledVersion.patch)) then + raise ESDL2Error.Create('SDL_VERSION or SDL_COMPILEDVERSION failed: Version results do not match!'); + + if not SDL_VERSION_ATLEAST(2,0,0) then + raise ESDL2Error.Create('SDL_VERSION_ATLEAST failed: Version at least 2.0.0 should be true!'); + + if SDL_VERSION_ATLEAST(3,0,0) then + raise ESDL2Error.Create('SDL_VERSION_ATLEAST failed: Version at least 3.0.0 should be false!'); + + SDL_GetVersion(@LinkedVersion); + if @LinkedVersion = nil then + raise ESDL2Error.Create('SDL_GetVersion failed: ' + SDL_GetError()); + + if SDL_VERSIONNUM(LinkedVersion.major, LinkedVersion.minor, LinkedVersion.patch) = 0 then + raise ESDL2Error.Create('SDL_GetVersion failed: Returns 0.0.0 .'); + except + end; + + writeln('finished.'); +end. +