Commit 76e189a0 authored by Sergio Costas's avatar Sergio Costas

Added test to check using incorrect parameter types when calling function pointers

parent e14fa907
......@@ -354,5 +354,18 @@ class Test(unittest.TestCase):
def testFunctionPointerIncorrectNumberOfParameters2(self):
self._generic_test("unitest/test86.c",[ (crusty.crusty.MSG_CRITICAL,"Calling function '{:s}' at line {:d} with an incorrect number of parameters","test1",7) ])
def testFunctionPointerExpectedCrustParameter(self):
self._generic_test("unitest/test87.c",[ (crusty.crusty.MSG_CRITICAL,"Expected a __crust_t__ variable at parameter {:d} when calling function '{:s}' at line {:d}, but passed non __crust_t__ variable",1,"test1",10) ])
def testFunctionPointerExpectedCrustParameter2(self):
self._generic_test("unitest/test88.c",[ (crusty.crusty.MSG_CRITICAL,"Expected a __crust_t__ variable at parameter {:d} when calling function '{:s}' at line {:d}, but passed non __crust_t__ variable",1,"test1",8) ])
def testFunctionPointerExpectedNonCrustParameter(self):
self._generic_test("unitest/test89.c",[ (crusty.crusty.MSG_CRITICAL,"Expected a non __crust_t__ variable at parameter {:d} when calling function '{:s}' at line {:d}, but passed a __crust_t__ variable",1,"test1",11) ])
def testFunctionPointerExpectedNonCrustParameter2(self):
self._generic_test("unitest/test90.c",[ (crusty.crusty.MSG_CRITICAL,"Expected a non __crust_t__ variable at parameter {:d} when calling function '{:s}' at line {:d}, but passed a __crust_t__ variable",1,"test1",9) ])
if __name__ == '__main__':
unittest.main()
typedef __crust_t__ unsigned char *crust_t;
typedef char* (*prueba)(crust_t);
#define NULL ((void *)0)
void main(crust_t param1) {
prueba test1 = main;
int b = 1;
(*test1)(b); // ERROR: calling a function pointer with an incorrect type of parameters
__crust_disable__
}
typedef __crust_t__ unsigned char *crust_t;
#define NULL ((void *)0)
void main(crust_t param1) {
char* (*test1)(crust_t) = main;
int b = 1;
(*test1)(b); // ERROR: calling a function pointer with incorrect type of parameters
__crust_disable__
}
typedef __crust_t__ unsigned char *crust_t;
typedef void (*prueba)(int);
#define NULL ((void *)0)
void function(int);
void main(crust_t param1) {
prueba test1 = function;
(*test1)(param1); // ERROR: calling a function pointer with an incorrect type of parameters
__crust_disable__
}
typedef __crust_t__ unsigned char *crust_t;
#define NULL ((void *)0)
void function(int);
void main(crust_t param1) {
void (*test1)(int) = function;
(*test1)(param1); // ERROR: calling a function pointer with incorrect type of parameters
__crust_disable__
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment