-
Notifications
You must be signed in to change notification settings - Fork 7
Added support for generating Unity style tests #9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
… used by the Unity test generation
Updated unit tests to reflect the Unity style
Now pass in either "unity" or "simple" to use the two generators. Updated tests to pass in unity.
Updated tests to use these new asserts
This allows chartacer returns to look more correct and makes the assertions more precise.
Unions currently do not work - this test demonstrates this https://github.com/diffblue/verification-engine-utils/issues/355
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A checklist of newly introduced whitespace changes I should fix. Can't make it a request changes on my own PR...
@@ -305,9 +306,10 @@ bool bmc_covert::operator()() | |||
for(const auto & it : goal_map) | |||
if(it.second.satisfied) goals_covered++; | |||
|
|||
if (bmc.options.get_bool_option("gen-c-test-case")) | |||
if (bmc.options.get_option("gen-c-test-case") != "") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Spacing
{ | ||
|
||
std::string generator_str = bmc.options.get_option("gen-c-test-case"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Spacing
c_simple_test_case_generatort gen(get_message_handler(), bmc.options, | ||
bmc.ns.get_symbol_table(), goto_functions, test, test_case_no, true); | ||
std::unique_ptr<c_test_case_generatort> gen; | ||
if(generator_str == "unity") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Spacing in this block x4
@@ -48,11 +49,14 @@ class c_test_case_generatort : public messaget | |||
|
|||
protected: | |||
virtual void add_includes(c_test_filet &test_file); | |||
virtual void add_main_method(c_test_filet &test_file, | |||
virtual void add_main_method(class c_test_filet &test_file, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Parameter on next line
#include <algorithm> | ||
#include <util/config.h> | ||
|
||
c_unity_test_case_generatort::c_unity_test_case_generatort(message_handlert &_message_handler, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does constructor need comment?
size_t test_index, | ||
bool using_test_main) | ||
: c_test_case_generatort(_message_handler, options, symbol_table, | ||
goto_functions, test, test_index, using_test_main) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Each of these should be on a separate line.
included inside this file | ||
\*******************************************************************/ | ||
void c_unity_test_case_generatort::add_main_method(c_test_filet &test_file, | ||
const testt &test) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Parameter on separate line.
return_value_var - The name of the variable (including relevant nesting) | ||
Purpose: Add an assertion for a unity expression | ||
\*******************************************************************/ | ||
void c_unity_test_case_generatort::add_simple_assert(c_test_filet &test_file, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Parameter on separate line.
class c_unity_test_case_generatort : public c_test_case_generatort | ||
{ | ||
public: | ||
c_unity_test_case_generatort(message_handlert &_message_handler, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Parameter on new line
|
||
protected: | ||
virtual void add_includes(class c_test_filet &test_file) override; | ||
virtual void add_main_method(class c_test_filet &test_file, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Parameter on new line x4
d69dfd5
to
33a98bb
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
very nice
const testt &test, | ||
size_t test_index, | ||
bool using_test_main) | ||
: c_test_case_generatort( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
put colon on the previous line; "c_test_case_generator(" is aligned with bool; its arguments are indented (as they are already)
Fixed white space and other linting errors in lines touched by this PR.
33a98bb
to
eed8e8a
Compare
Added a new class to generate Unity style tests. These include nice reporting of whether the test passes or fails as well as handling more sophisticated assertions.
Most of the regression files are modified as the format of the test is different.