Difference between revisions of "Scl test cclass"

From STRIDE Wiki
Jump to: navigation, search
(Notes)
Line 26: Line 26:
  
 
== Notes ==
 
== Notes ==
* The test C class identified must:
+
* This pragma:
** Have a public constructor.
+
** Requires the inclusion of srtest.h prior to its declaration.
** The constructor may have parameters, but they must all be POD type.
+
** Requires STRIDE version 2.1 or later.
** Have one or more member functions that suitable as a test method. For a member function to be a test method it must:
+
** Requires that the host PC have a recent ActiveState Perl distribution installed.
*** be declared within the test class (method not declared, but inherited from a base class cannot be test methods)
+
** Synthesizes a function with the following declaration:
*** have a return type of bool, an integral type (signed or unsigned long, int, short, char) or void.
+
      extern "C" srTestCaseTotals_t cclass-name();
*** have an empty parameter list. That is, declared as f() or f(void).
+
  where the cclass-name is the user-declared cclass name.
*** not be a templatized function
+
 
*** not be an overloaded operator
+
* The test C class identified:
*** The class cannot be a pure virtual class
+
** May not appear as a specifier of a prior pragma.
*** not be a static member.
+
** Must be a struct in C.
** Cannot be a templated class.
+
** Must be either a struct or class in C++.
** Cannot be a nested class.
+
** Must be [http://en.wikipedia.org/wiki/Plain_Old_Data_Structures POD] type.
* This pragma can only work in STRIDE version 2.1 or later.
+
** Must not be a template class.
* The host PC must also have a recent distribution of ActiveState Perl installed.
+
** Must not be a nested class.
 +
** Must contain at least one member function pointer with a prototype that returns an integral type: void, int, bool (bool only accepted for C++). This prototype must contain a pointer-to-CClass as its first parameter.
 +
 
 +
* The initialization routine:
 +
** Must be declared prior to this 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 cclass.
 +
 
 +
* The deinitialization routine:
 +
** Is optional.
 +
** Must be declared prior to this pragma 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 ==
 
== Examples ==

Revision as of 16:00, 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

  • 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();
  where the cclass-name is the user-declared cclass name.
  • The test C class 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 an integral type: void, int, bool (bool only accepted for C++). This prototype must contain a pointer-to-CClass as its first parameter.
  • The initialization routine:
    • Must be declared prior to this 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 cclass.
  • The deinitialization routine:
    • Is optional.
    • Must be declared prior to this pragma 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