Scl test cclass

From STRIDE Wiki
Revision as of 22:12, 31 July 2008 by Chrisj (talk | contribs) (→‎Notes)
Jump to navigation Jump to search

The scl_test_cclass pragma

The scl_test_cclass pragma one of the Test Unit pragmas. 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

  • This pragma:
    • requires the inclusion of srtest.h prior to its declaration.
    • requires STRIDE version 2.1 or later.
    • requires that the host PC have a recent ActiveState Perl distribution installed.
    • synthesizes a function with the following declaration:
     extern "C" srTestCaseTotals_t cclass-name();
  • The cclass-name identified:
    • may not appear as a specifier of a prior pragma.
    • must be a struct in C.
    • must be either a struct or class in C++.
    • must be POD type.
    • must not be a template class.
    • must not be a nested class.
    • must contain at least one member function pointer with a prototype that:
      • returns integral type: void, int, or bool (bool accepted only for C++).
      • has a first parameter that is a pointer to cclass-name.
  • The init-function-name identified:
    • must be declared prior to this pragma's declaration.
    • must not have been used in any prior or subsequent SCL pragma.
    • must have its first parameter declared as a pointer to the identified cclass.
  • The deinit-function-name:
    • is optional.
    • must be declared prior to this pragma's declaration if it appears in pragma.
    • must not have been used in any prior or subsequent SCL pragma.
    • must have its first parameter declared as a pointer to the identified class.

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