Difference between revisions of "Scl test flist"

From STRIDE Wiki
Jump to: navigation, search
(See Also)
(Syntax)
 
(11 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 
= The scl_test_flist pragma =
 
= The scl_test_flist pragma =
  
The scl_test_flist pragma is one of the [[SCL_Pragmas#Test_Units|Test Unit]] pragmas. It captures a list of external functions as a Test Unit. Once captured, each external function becomes a test method. STRIDE will generate appropriate code for execution of the test methods.
+
The ''scl_test_flist'' pragma is one of the [[SCL_Pragmas#Test_Units|Test Unit]] pragmas. It captures a list of external functions as a Test Unit. Once captured, each external function becomes a test method. STRIDE will generate appropriate code for execution of the test methods.
  
 
== Syntax ==
 
== Syntax ==
Line 14: Line 14:
 
| ''test-unit-name''
 
| ''test-unit-name''
 
| String
 
| String
| Name of test unit into which a list of external functions will be assembled.
+
| The name of the test unit. A special '''identifier''' with that name will be synthesized into which the list of external functions will be assembled.  
 +
'''''Note:''' this string may not contain a space.''
 
|-  
 
|-  
 
| ''function-1''
 
| ''function-1''
| String
+
| Identifier
 
| Name of the first external function to be captured.
 
| Name of the first external function to be captured.
 
|-  
 
|-  
 
| ''function-2..n [Optional]''
 
| ''function-2..n [Optional]''
| String
+
| Identifier
 
| Optional names of second and subsequent external functions to be captured.
 
| Optional names of second and subsequent external functions to be captured.
 
|}
 
|}
Line 41: Line 42:
 
* The test-unit-name may not have been specified with a prior scl_test_flist pragma.
 
* The test-unit-name may not have been specified with a prior scl_test_flist pragma.
 
* The test-unit-name may not be the name of an existing routine.
 
* The test-unit-name may not be the name of an existing routine.
* In CPP-compile mode, the external function(s) must have been declared using 'extern "C"'.
+
* Optionally if desired a set of [[scl_test_setup|setup]]/[[scl_test_teardown|teardown]] fixtures could be applied.
* There is no way to associate a SMID value with an external function, as with scl_func.
 
  
 
== Examples ==
 
== Examples ==
 
<source lang=c>
 
<source lang=c>
 
#include <srtest.h>
 
#include <srtest.h>
 +
 +
#ifdef __cplusplus
 +
extern "C" {
 +
#endif
  
 
int test1();
 
int test1();
 
int test2();
 
int test2();
 +
 +
#ifdef __cplusplus
 +
}
 +
#endif
 
   
 
   
 
#ifdef _SCL
 
#ifdef _SCL
Line 57: Line 65:
  
 
== See Also ==
 
== See Also ==
* Refer to the [[Test Function List Sample]] page for more information on capturing and qualifying test units.
+
* Refer to the [[Test Function List Samples]] page for more information on capturing and qualifying test units.
  
 
[[Category: Test Units]]
 
[[Category: Test Units]]
 
[[Category: SCL]]
 
[[Category: SCL]]

Latest revision as of 21:29, 14 June 2011

The scl_test_flist pragma

The scl_test_flist pragma is one of the Test Unit pragmas. It captures a list of external functions as a Test Unit. Once captured, each external function becomes a test method. STRIDE will generate appropriate code for execution of the test methods.

Syntax

#pragma scl_test_flist(test-unit-name, function-1, function-2..n)
Parameters Type Description
test-unit-name String The name of the test unit. A special identifier with that name will be synthesized into which the list of external functions will be assembled.

Note: this string may not contain a space.

function-1 Identifier Name of the first external function to be captured.
function-2..n [Optional] Identifier Optional names of second and subsequent external functions to be captured.

Notes

  • The external functions must meet the following conditions:
    • Their parameter lists must be empty (void).
    • They cannot be overloaded.
    • They cannot be overloaded operators.
    • They may not be template functions.
    • They may throw exceptions when compiled in CPP mode.
    • They cannot have been previously captured with scl_function, or another scl_test_flist pragma.
    • They cannot be public static class methods.
    • They must return a pass/fail result. The return type may be declared void or an integer type (bool is acceptable in C++ mode). If void is the return type, any calls to the test function default to successful.
  • Once an external function has been captured with scl_test_flist, that function may not then be captured again with an scl_function pragma, or another scl_test_flist pragma, or used with any other qualification pragmas.
  • Use of this pragma requires an include of srtest.h.
  • The test-unit-name may not have been specified with a prior scl_test_flist pragma.
  • The test-unit-name may not be the name of an existing routine.
  • Optionally if desired a set of setup/teardown fixtures could be applied.

Examples

#include <srtest.h>

#ifdef __cplusplus
extern "C" {
#endif

int test1();
int test2();

#ifdef __cplusplus
}
#endif
 
#ifdef _SCL
#pragma scl_test_flist("Foo", test1, test2)
#endif

See Also