Scl test cclass: Difference between revisions
Jump to navigation
Jump to search
(→Syntax) |
(→Syntax) |
||
Line 9: | Line 9: | ||
{| border="1" cellspacing="0" cellpadding="10" style="align:left;" | {| border="1" cellspacing="0" cellpadding="10" style="align:left;" | ||
| width="190" bgcolor="#66ff99" | '''Parameters''' | | width="190" bgcolor="#66ff99" | '''Parameters''' | ||
| width=" | | width="100" bgcolor="#66ff99" | '''Type''' | ||
| bgcolor="#66ff99" | '''Description''' | | bgcolor="#66ff99" | '''Description''' | ||
|- | |- | ||
| ''cclass-name'' | | ''cclass-name'' | ||
| Object | | Object | ||
| The name of the test cclass. This is a struct name in C. It is a struct or class name in C++. | | The name of the test cclass. This is a struct name in C. It is a struct or class name in C++. | ||
|- | |- | ||
| ''init-function-name'' | | ''init-function-name'' | ||
| Identifier | | Identifier | ||
| The initialization function name. This is synonymous with a class constructor. | | The initialization function name. This is synonymous with a class constructor. There must be a prior user-declared function with this name. The first parameter must be a pointer to cclass-name. Additional parameters are left up to the user's implementation. | ||
|- | |- | ||
| ''deinit-function-name (optional)'' | | ''deinit-function-name (optional)'' | ||
| Identifier | | Identifier | ||
| The deinitialization function name. This is synonymous with a class destructor. | | The deinitialization function name. This is synonymous with a class destructor. If declared, there must be a user-declared function with this name. The first parameter must be a pointer to cclass-name. Additional parameters are left up to the user's implementation. | ||
|} | |} | ||
Revision as of 21:36, 31 July 2008
The scl_test_cclass pragma
The scl_test_cclass pragma declares a "C" language struct (class) to be captured as a test unit. Once captured, STRIDE will generate the appropriate code for executing test methods defined for this "C" Class.
Syntax
#pragma scl_test_cclass(cclass-name, init-function-name { , deinit-function-name })
Parameters | Type | Description |
cclass-name | Object | The name of the test cclass. This is a struct name in C. It is a struct or class name in C++. |
init-function-name | Identifier | The initialization function name. This is synonymous with a class constructor. There must be a prior user-declared function with this name. The first parameter must be a pointer to cclass-name. Additional parameters are left up to the user's implementation. |
deinit-function-name (optional) | Identifier | The deinitialization function name. This is synonymous with a class destructor. If declared, there must be a user-declared function with this name. The first parameter must be a pointer to cclass-name. Additional parameters are left up to the user's implementation. |
Notes
- The test C class identified must:
- Have a public constructor.
- The constructor may have parameters, but they must all be POD type.
- Have one or more member functions that suitable as a test method. For a member function to be a test method it must:
- be declared within the test class (method not declared, but inherited from a base class cannot be test methods)
- have a return type of bool, an integral type (signed or unsigned long, int, short, char) or void.
- have an empty parameter list. That is, declared as f() or f(void).
- not be a templatized function
- not be an overloaded operator
- The class cannot be a pure virtual class
- not be a static member.
- Cannot be a templated class.
- Cannot be a nested class.
- This pragma can only work in STRIDE version 2.1 or later.
- The host PC must also have a recent distribution of ActiveState Perl installed.
Examples
#include <srtest.h> typedef struct CClass_Basic_Simple { int (*pf_TestMethod)(struct CClass_Basic_Simple* pcc); } CClass_Basic_Simple; #ifdef __cplusplus extern "C" { #endif void CClass_Basic_Simple_init(struct CClass_Basic_Simple* pcc); #ifdef __cplusplus } #endif #ifdef _SCL #pragma scl_test_cclass(CClass_Basic_Simple, CClass_Basic_Simple_init) #endif
See Also
- Refer to the Test "C" Class Samples page for more information on capturing and qualifying test "C" classes.