mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-11 22:06:40 +02:00
+ added structure testing
This commit is contained in:
parent
03d841893e
commit
aa66edd3c9
@ -8,6 +8,19 @@ unsigned short global_u16bit;
|
|||||||
unsigned long global_u32bit;
|
unsigned long global_u32bit;
|
||||||
unsigned long long global_s64bit;
|
unsigned long long global_s64bit;
|
||||||
|
|
||||||
|
struct _3BYTE_
|
||||||
|
{
|
||||||
|
unsigned char u8;
|
||||||
|
unsigned short u16;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct _7BYTE_
|
||||||
|
{
|
||||||
|
unsigned char u8;
|
||||||
|
long long s64;
|
||||||
|
unsigned short u16;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
/* simple parameter testing */
|
/* simple parameter testing */
|
||||||
void test_param_u8(unsigned char v)
|
void test_param_u8(unsigned char v)
|
||||||
@ -51,9 +64,26 @@ void test_param_mixed_s64(unsigned char z, long long x, unsigned char y)
|
|||||||
global_u8bit = y;
|
global_u8bit = y;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* simple record testing */
|
||||||
|
void test_param_struct_small(struct _3BYTE_ buffer)
|
||||||
|
{
|
||||||
|
global_u8bit = buffer.u8;
|
||||||
|
global_u16bit = buffer.u16;
|
||||||
|
}
|
||||||
|
|
||||||
|
void test_param_struct_large(struct _7BYTE_ buffer)
|
||||||
|
{
|
||||||
|
global_u8bit = buffer.u8;
|
||||||
|
global_u16bit = buffer.u16;
|
||||||
|
global_s64bit = buffer.s64;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
$Log$
|
$Log$
|
||||||
Revision 1.1 2002-04-13 21:06:39 carl
|
Revision 1.2 2002-04-22 19:09:12 carl
|
||||||
|
+ added structure testing
|
||||||
|
|
||||||
|
Revision 1.1 2002/04/13 21:06:39 carl
|
||||||
+ c module testing
|
+ c module testing
|
||||||
|
|
||||||
*/
|
*/
|
Binary file not shown.
@ -21,12 +21,26 @@ program tcalext;
|
|||||||
{$R+}
|
{$R+}
|
||||||
|
|
||||||
{$L ctest.o}
|
{$L ctest.o}
|
||||||
|
{ Use C alignment of records }
|
||||||
|
{$PACKRECORDS C}
|
||||||
const
|
const
|
||||||
RESULT_U8BIT = $55;
|
RESULT_U8BIT = $55;
|
||||||
RESULT_U16BIT = $500F;
|
RESULT_U16BIT = $500F;
|
||||||
RESULT_U32BIT = $500F0000;
|
RESULT_U32BIT = $500F0000;
|
||||||
RESULT_S64BIT = -12000;
|
RESULT_S64BIT = -12000;
|
||||||
|
|
||||||
|
type
|
||||||
|
_3byte_ = record
|
||||||
|
u8 : byte;
|
||||||
|
u16 : word;
|
||||||
|
end;
|
||||||
|
|
||||||
|
_7byte_ = record
|
||||||
|
u8: byte;
|
||||||
|
s64: int64;
|
||||||
|
u16: word;
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
{ simple parameter passing }
|
{ simple parameter passing }
|
||||||
procedure test_param_u8(x: byte); cdecl; external;
|
procedure test_param_u8(x: byte); cdecl; external;
|
||||||
@ -37,6 +51,13 @@ procedure test_param_s64(x: int64); cdecl; external;
|
|||||||
procedure test_param_mixed_u16(z: byte; x : word; y :byte); cdecl; external;
|
procedure test_param_mixed_u16(z: byte; x : word; y :byte); cdecl; external;
|
||||||
procedure test_param_mixed_u32(z: byte; x: cardinal; y: byte); cdecl; external;
|
procedure test_param_mixed_u32(z: byte; x: cardinal; y: byte); cdecl; external;
|
||||||
procedure test_param_mixed_s64(z: byte; x: int64; y: byte); cdecl; external;
|
procedure test_param_mixed_s64(z: byte; x: int64; y: byte); cdecl; external;
|
||||||
|
{ structure parameter testing }
|
||||||
|
procedure test_param_struct_small(buffer : _3BYTE_); cdecl; external;
|
||||||
|
procedure test_param_struct_large(buffer : _7BYTE_); cdecl; external;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
var
|
var
|
||||||
@ -73,6 +94,8 @@ var
|
|||||||
|
|
||||||
|
|
||||||
var failed : boolean;
|
var failed : boolean;
|
||||||
|
smallstruct : _3BYTE_;
|
||||||
|
bigstruct : _7BYTE_;
|
||||||
begin
|
begin
|
||||||
Write('External simple parameter testing...');
|
Write('External simple parameter testing...');
|
||||||
failed := false;
|
failed := false;
|
||||||
@ -155,11 +178,49 @@ begin
|
|||||||
else
|
else
|
||||||
WriteLn('Passed!');
|
WriteLn('Passed!');
|
||||||
|
|
||||||
|
Write('External struct parameter testing...');
|
||||||
|
|
||||||
|
failed := false;
|
||||||
|
|
||||||
|
clear_values;
|
||||||
|
clear_globals;
|
||||||
|
|
||||||
|
smallstruct.u8 := RESULT_U8BIT;
|
||||||
|
smallstruct.u16 := RESULT_u16BIT;
|
||||||
|
test_param_struct_small(smallstruct);
|
||||||
|
if global_u16bit <> RESULT_U16BIT then
|
||||||
|
failed := true;
|
||||||
|
if global_u8bit <> RESULT_U8BIT then
|
||||||
|
failed := true;
|
||||||
|
|
||||||
|
clear_values;
|
||||||
|
clear_globals;
|
||||||
|
|
||||||
|
|
||||||
|
bigstruct.u8 := RESULT_U8BIT;
|
||||||
|
bigstruct.u16 := RESULT_U16BIT;
|
||||||
|
bigstruct.s64 := RESULT_S64BIT;
|
||||||
|
test_param_struct_large(bigstruct);
|
||||||
|
if global_s64bit <> RESULT_S64BIT then
|
||||||
|
failed := true;
|
||||||
|
if global_u16bit <> RESULT_U16BIT then
|
||||||
|
failed := true;
|
||||||
|
if global_u8bit <> RESULT_U8BIT then
|
||||||
|
failed := true;
|
||||||
|
|
||||||
|
If failed then
|
||||||
|
fail
|
||||||
|
else
|
||||||
|
WriteLn('Passed!');
|
||||||
|
|
||||||
end.
|
end.
|
||||||
|
|
||||||
{
|
{
|
||||||
$Log$
|
$Log$
|
||||||
Revision 1.1 2002-04-13 21:03:43 carl
|
Revision 1.2 2002-04-22 19:09:28 carl
|
||||||
|
+ added structure testing
|
||||||
|
|
||||||
|
Revision 1.1 2002/04/13 21:03:43 carl
|
||||||
+ C module testing (unfinished)
|
+ C module testing (unfinished)
|
||||||
|
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user