Scl test cclass

From STRIDE Wiki
Revision as of 15:32, 31 July 2008 by Chrisj (talk | contribs)
Jump to: navigation, search

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 (struct or class) The name of the test struct (can be a class in C++) to be captured.
init-function-name Identifier (Function Name) The initialization function name. This is synonymous with a class constructor. The first parameter of this user-declared function must be a pointer to cclass-name. Other parameters are left up to the user's implementation.
deinit-function-name (optional) Identifier (Function Name) The deinitialization function name. This is synonymous with a class destructor. The first parameter of this user-declared function must be a pointer to cclass-name. Other 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