projects
/
openssl.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Change SETUP_TEST_FIXTURE so that the fixture structure is passed by
[openssl.git]
/
test
/
testutil.h
diff --git
a/test/testutil.h
b/test/testutil.h
index 399f521a4e9e9ec3c740fe61334f40292333f830..f779fd53053e505311d4cbfe556ed7d2478d894b 100644
(file)
--- a/
test/testutil.h
+++ b/
test/testutil.h
@@
-65,12
+65,13
@@
* SETUP_TEST_FIXTURE will call set_up() to create a new TEST_FIXTURE_TYPE
* object called "fixture". It will also allocate the "result" variable used
* by EXECUTE_TEST. set_up() should take a const char* specifying the test
* SETUP_TEST_FIXTURE will call set_up() to create a new TEST_FIXTURE_TYPE
* object called "fixture". It will also allocate the "result" variable used
* by EXECUTE_TEST. set_up() should take a const char* specifying the test
- * case name and return a TEST_FIXTURE_TYPE by
valu
e.
+ * case name and return a TEST_FIXTURE_TYPE by
referenc
e.
*
*
- * EXECUTE_TEST will pass fixture to execute_func() by
valu
e, call
+ * EXECUTE_TEST will pass fixture to execute_func() by
referenc
e, call
* tear_down(), and return the result of execute_func(). execute_func() should
* tear_down(), and return the result of execute_func(). execute_func() should
- * take a TEST_FIXTURE_TYPE by value and return 1 on success and 0 on
- * failure.
+ * take a TEST_FIXTURE_TYPE by reference and return 1 on success and 0 on
+ * failure. The tear_down function is responsible for deallocation of the
+ * result variable, if required.
*
* Unit tests can define their own SETUP_TEST_FIXTURE and EXECUTE_TEST
* variations like so:
*
* Unit tests can define their own SETUP_TEST_FIXTURE and EXECUTE_TEST
* variations like so:
@@
-91,13
+92,14
@@
* }
*/
# define SETUP_TEST_FIXTURE(TEST_FIXTURE_TYPE, set_up)\
* }
*/
# define SETUP_TEST_FIXTURE(TEST_FIXTURE_TYPE, set_up)\
- TEST_FIXTURE_TYPE fixture = set_up(TEST_CASE_NAME); \
+ TEST_FIXTURE_TYPE
*
fixture = set_up(TEST_CASE_NAME); \
int result = 0
# define EXECUTE_TEST(execute_func, tear_down)\
int result = 0
# define EXECUTE_TEST(execute_func, tear_down)\
+ if (fixture != NULL) {\
result = execute_func(fixture);\
tear_down(fixture);\
result = execute_func(fixture);\
tear_down(fixture);\
- return result
+ }
/*
* TEST_CASE_NAME is defined as the name of the test case function where
/*
* TEST_CASE_NAME is defined as the name of the test case function where