Scl test class: Difference between revisions
Jump to navigation
Jump to search
(→Notes) |
No edit summary |
||
Line 19: | Line 19: | ||
== Notes == | == Notes == | ||
* This pragma requires the compilation language to be C++. If the compilation language is not C++ and this pragma is encountered, then an error is issued and this pragma is ignored. | * This pragma requires the compilation language to be C++. If the compilation language is not C++ and this pragma is encountered, then an error is issued and this pragma is ignored. | ||
* The test class identified: | * The test class identified: | ||
** | ** must have single public constructor - default or explicit. | ||
** | ** must not be a templated class | ||
** | ** must not be a nested class | ||
** | ** must not be a pure virtual class | ||
** | ** must have one or more member functions that is suitable as a test method. For a member function to be a test method it: | ||
*** | *** must be declared within the test class (a method that is inherited from a base class cannot be a test method) | ||
*** | *** must have a return type of bool, an integral type (signed or unsigned long, int, short, char) or void. | ||
*** | *** must have an empty parameter list - declared as f() or f(void). | ||
*** | *** must not be a templatized function | ||
*** | *** must not be an overloaded operator | ||
*** | *** must not be a static member. | ||
* Optionally if desired a set of [[scl_test_setup|setup]]/[[scl_test_teardown|teardown]] fixtures could be applied. | * Optionally if desired a set of [[scl_test_setup|setup]]/[[scl_test_teardown|teardown]] fixtures could be applied. | ||
* Optionally if desired the public constructor may have parameters (they must all be [http://en.wikipedia.org/wiki/Plain_Old_Data_Structures POD] type). For which concrete values could be specified when [[Stride_Runner#Input|running]] the test unit. | |||
== Examples == | == Examples == | ||
Line 43: | Line 47: | ||
// Declaring a constructor for an scl_test_class is optional, but | // Declaring a constructor for an scl_test_class is optional, but | ||
// if a constructor is declared all parameters must be of plain old data (POD) type. | // if a constructor is declared all parameters must be of plain old data (POD) type. | ||
RuntimeServices_dynamic(int i, const char* s); | |||
RuntimeServices_dynamic(int i, | |||
}; | }; | ||
Revision as of 23:08, 25 May 2010
The scl_test_class pragma
The scl_test_class pragma is one of the Test Unit pragmas. It declares a test class as captured. Once captured, the STRIDE compiler will generate the appropriate code in the Intercept Module (IM) for instantiating the class and executing its test methods.
Syntax
#pragma scl_test_class(class-name)
Parameters | Type | Description |
class-name | String | The name of the test class to be captured. Once captured, STRIDE will generate the appropriate code for executing the test methods in the class. |
Notes
- This pragma requires the compilation language to be C++. If the compilation language is not C++ and this pragma is encountered, then an error is issued and this pragma is ignored.
- The test class identified:
- must have single public constructor - default or explicit.
- must not be a templated class
- must not be a nested class
- must not be a pure virtual class
- must have one or more member functions that is suitable as a test method. For a member function to be a test method it:
- must be declared within the test class (a method that is inherited from a base class cannot be a test method)
- must have a return type of bool, an integral type (signed or unsigned long, int, short, char) or void.
- must have an empty parameter list - declared as f() or f(void).
- must not be a templatized function
- must not be an overloaded operator
- must not be a static member.
- Optionally if desired the public constructor may have parameters (they must all be POD type). For which concrete values could be specified when running the test unit.
Examples
#include <srtest.h>
class RuntimeServices_dynamic {
public:
void dynamic(void);
// Declaring a constructor for an scl_test_class is optional, but
// if a constructor is declared all parameters must be of plain old data (POD) type.
RuntimeServices_dynamic(int i, const char* s);
};
#ifdef _SCL
#pragma scl_test_class(RuntimeServices_dynamic)
#endif
See Also
- Refer to the Test Class Samples page for more information on capturing and qualifying test classes.