+ test for windows which tests if an .rc file can be really compiled into an .res file

git-svn-id: trunk@27042 -
This commit is contained in:
florian 2014-03-09 10:54:33 +00:00
parent 2c5a0ffc89
commit c9f7c7d88c
3 changed files with 65 additions and 0 deletions

2
.gitattributes vendored
View File

@ -12334,6 +12334,8 @@ tests/test/units/system/tres3.pp svneol=native#text/plain
tests/test/units/system/tres3ext.pp svneol=native#text/plain
tests/test/units/system/tres4.pp svneol=native#text/plain
tests/test/units/system/tres4.res -text
tests/test/units/system/tres5.pp svneol=native#text/plain
tests/test/units/system/tres5.rc svneol=native#text/plain
tests/test/units/system/tresb.rc svneol=native#text/plain
tests/test/units/system/tresb.res -text
tests/test/units/system/tresext.pp svneol=native#text/plain

View File

@ -0,0 +1,61 @@
{ Test for resources support from .rc files. }
{%TARGET=win32,win64}
{$mode objfpc}
uses sysutils;
{$R tres5.rc}
procedure Fail(const Msg: string);
begin
writeln(Msg);
Halt(1);
end;
function GetResource(ResourceName, ResourceType: PChar; PResSize: PLongInt = nil): pointer;
var
hRes: TFPResourceHandle;
gRes: TFPResourceHGLOBAL;
begin
hRes:=FindResource(HINSTANCE, ResourceName, ResourceType);
if hRes = 0 then
Fail('FindResource failed.');
gRes:=LoadResource(HINSTANCE, hRes);
if gRes = 0 then
Fail('LoadResource failed.');
if PResSize <> nil then begin
PResSize^:=SizeofResource(HINSTANCE, hRes);
if PResSize^ = 0 then
Fail('SizeofResource failed.');
end;
Result:=LockResource(gRes);
if Result = nil then
Fail('LockResource failed.');
end;
procedure DoTest;
var
s: string;
p: PChar;
sz: longint;
begin
p:=GetResource('TestFile', 'FILE', @sz);
SetString(s, p, sz);
if s <> 'test file.' then
Fail('Invalid resource loaded.');
writeln(s);
p:=GetResource('Test', 'TEXT', @sz);
SetString(s, p, sz);
if s <> 'Another test file.' then
Fail('Invalid resource loaded.');
writeln(s);
end;
begin
writeln('Resources test.');
DoTest;
writeln('Done.');
end.

View File

@ -0,0 +1,2 @@
TestFile FILE "tres1.txt"
Test TEXT "tres2.txt"