Skip to content

Parameterized suite, parameterized test + cmd commands #124

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

Closed
wants to merge 135 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
135 commits
Select commit Hold shift + click to select a range
d083237
Imported files from other project
killoctal May 11, 2016
68118d6
removed dependency to <functional> (and lambdas)
killoctal May 11, 2016
d8a5370
pass values in constructor instead of template argument
killoctal May 11, 2016
d01652f
removed cascading constructor
killoctal May 11, 2016
2a3c4ef
removed dependency to <memory> and unique_pointer
killoctal May 11, 2016
313830b
fixed uncoherent test name
killoctal May 11, 2016
a05e709
added endl after warning
killoctal May 12, 2016
a6c56fe
less C++11
killoctal May 13, 2016
ab3cc22
created macro SET_SUITE_PARAMETERS
killoctal May 13, 2016
1dbb31f
updated tests for using macros
killoctal May 13, 2016
0a3c699
little macro syntax change
killoctal May 13, 2016
abb0667
created macro PARAMETERIZED_SUITE (usage is like SUITE marco)
killoctal May 13, 2016
1966eee
created test
killoctal May 13, 2016
8800546
changed params order
killoctal May 13, 2016
f9f3523
added some const methods
killoctal May 13, 2016
17ec122
splitted class in .h/.cpp
killoctal May 13, 2016
f6f0777
created empty class ParameterizedTest
killoctal May 14, 2016
a1510a1
method for retrieve a test from its details
killoctal May 14, 2016
908f7b5
throw exception if test not retrieved
killoctal May 14, 2016
0be4fef
non static members
killoctal May 14, 2016
183209f
coded feature
killoctal May 14, 2016
e525453
created simple test (not passing yet)
killoctal May 14, 2016
9ec5722
fixed test
killoctal May 14, 2016
1f2c10d
prevent for empty values
killoctal May 14, 2016
77fef1d
bug fix
killoctal May 14, 2016
e558ada
fix: nested tests
killoctal May 14, 2016
2102d05
updated macro for use test instead of suite
killoctal May 15, 2016
817fbc8
added callback feature
killoctal May 15, 2016
29bb785
migrated tests
killoctal May 15, 2016
1a1e041
totally removed class "ParameterizedSuite"
killoctal May 15, 2016
2bfb49d
improved tests
killoctal May 15, 2016
6233fbc
reuse & nested test
killoctal May 15, 2016
6c565da
created class TestListNode
killoctal May 17, 2016
fe90cf0
moved usage Test::m_nextTest -> TestListNode::m_next
killoctal May 17, 2016
a6eb17f
updated tests
killoctal May 17, 2016
d584ccf
created SuitePredicate
killoctal May 17, 2016
ead64fc
created RunTestsCmd for easyly run test(s) or suite(s) (use command "…
killoctal May 17, 2016
dabb1d2
applyed to main
killoctal May 17, 2016
07a31f4
Merge branch 'TestListUndependant' into ParameterizedSuite
killoctal May 17, 2016
cb852cb
use char* instead of string (for dll export)
killoctal May 17, 2016
bbdf7c7
updated for using new TestListNode
killoctal May 17, 2016
d49ddee
Create anchor with exactly same details than original test for ensure…
killoctal May 17, 2016
62941ba
minor simplification
killoctal May 17, 2016
1b2c3c5
Merge branch 'TestListUndependant' into ParameterizedSuite
killoctal May 17, 2016
ab89bf3
do not store current value for avoir problem "no default constructor …
killoctal May 18, 2016
d17a772
renamed "value" to "parameter"
killoctal May 19, 2016
7a01101
fixed macro: no more friend class, use namespace, method defined insi…
killoctal May 20, 2016
1096f19
use static vars for give possibility to create common instances
killoctal May 20, 2016
2ba324f
changed "int count" to "size_t count" for 64 bit portability (remove …
killoctal May 24, 2016
00aac47
Merge branch 'smallFixes' into ParameterizedSuite
killoctal May 24, 2016
5399af7
little test simplification
killoctal Jun 5, 2016
ab3298b
created class ParameterizedManager
killoctal Jun 7, 2016
b459589
moved test retriever
killoctal Jun 7, 2016
ba7c472
implemented manager
killoctal Jun 7, 2016
807cc81
added test for working with fixtures (not passing yet)
killoctal Jun 7, 2016
60165e4
fixed execution failure with Fixture
killoctal Jun 7, 2016
bd67474
protection against nested test
killoctal Jun 7, 2016
bbe4c88
Revert "fixed execution failure with Fixture"
killoctal Jun 7, 2016
94295a0
improved protection (revert prev commit was not suffisciant)
killoctal Jun 7, 2016
4247f78
removed warning "size_t to int conversion possible loss of data"
killoctal Jun 7, 2016
2991b08
removed tests storage (now useless because of begin/finish notion)
killoctal Jun 7, 2016
3236f62
code cleaning
killoctal Jun 7, 2016
124d448
revert revert (finally it is useful)
killoctal Jun 8, 2016
69d2a14
created clean method
killoctal Jun 8, 2016
733b73d
parameterized tests have names
killoctal Jun 8, 2016
226b31f
dump names with indexes ability
killoctal Jun 8, 2016
ac3718d
dump is added in reporter
killoctal Jun 8, 2016
b593259
removed zombie code
killoctal Jun 8, 2016
5a4c648
cleaned dependencies
killoctal Jun 8, 2016
c096b44
added "use several" test, bug found
killoctal Jun 8, 2016
dd2d98f
fixed bug
killoctal Jun 8, 2016
1a29081
ability to reuse a parameterized test (and "redeclaration error" prot…
killoctal Jun 9, 2016
5bd95da
more easy, 1 single macro
killoctal Jun 9, 2016
b103813
parameters order change
killoctal Jun 9, 2016
977172e
fixed test
killoctal Jun 9, 2016
8859f8e
created test FailedMessage_ContainsIndexes
killoctal Jun 15, 2016
724c803
fixed error message memory
killoctal Jun 15, 2016
ec13c8d
method for check if it is twice the same test from TestDetails
killoctal Jun 15, 2016
c0fad1b
added tests
killoctal Jun 15, 2016
c365265
use TestDetails::sameTest in parameterized
killoctal Jun 15, 2016
17f55d9
fixed test FailedMessage_ContainsIndexes
killoctal Jun 15, 2016
fd9e19e
changed sentence
killoctal Jun 15, 2016
269cc15
parameters listed on a single line
killoctal Jun 17, 2016
7c89e14
loop only if there is a parameter
killoctal Jun 20, 2016
8b1cb0b
cleaning
killoctal Jun 20, 2016
4373207
moved iteration FIRST/IDLE/ITERATE handling in manager
killoctal Jun 20, 2016
d14a47d
created excludeIndex functionality
killoctal Jun 20, 2016
24bf591
forbid exclude while iterating
killoctal Jun 20, 2016
423c03b
rename functionality to "ignoreIndex"
killoctal Jun 20, 2016
58d402a
ignore by value
killoctal Jun 20, 2016
119c7e2
simplification
killoctal Jun 20, 2016
e583e3d
clean ignored indexes only at end of iteration cycle
killoctal Jun 20, 2016
7df39dd
global ignore + tests
killoctal Jun 20, 2016
bc5161f
simplification: use struct instead of parralel maps
killoctal Jun 20, 2016
9c13b30
added test IgnoreIndex_IgnoreLast which revealed a bug
killoctal Jul 1, 2016
fdbc313
fixed ignore bug
killoctal Jul 1, 2016
a82ebbd
removed now useless code
killoctal Jul 1, 2016
a5d13e3
renamed "iteration" -> "index"
killoctal Jul 1, 2016
1ccb213
cleaned macro
killoctal Jul 1, 2016
e33f47e
added missing include
killoctal Jul 2, 2016
36dac71
removed useless var
killoctal Jul 2, 2016
7c5415c
renamed class "ParameterizedTest" -> "TestParameter"
killoctal Jul 2, 2016
058812b
use parameter naming convention "pz*"
killoctal Jul 2, 2016
28576ac
SET_SUITE_PARAMETERS -> SET_SUITE_PARAMETER
killoctal Jul 2, 2016
c340b40
SET_SUITE_PARAMETER -> SET_TEST_PARAMETER
killoctal Jul 4, 2016
a15549d
parameters -> values
killoctal Jul 4, 2016
aca5bc0
test LoopIsNotDetectableInTestList
killoctal Jul 8, 2016
256ac0b
LoopIsNotDetectableInTestList_Verify
killoctal Jul 8, 2016
4b43692
loop only during phasis end->begin (for stay undetectable)
killoctal Jul 8, 2016
8fca8ed
minor test enforcement
killoctal Jul 8, 2016
cb32b4f
getCurrentTest returns node instead of test
killoctal Jul 8, 2016
4a51b5d
tests rename
killoctal Jul 8, 2016
328f64b
rename "parameters" to "values"
killoctal Jul 12, 2016
90c678e
minor chage: const ref
killoctal Jul 12, 2016
7ed0732
do not throw exception if index out of range
killoctal Jul 12, 2016
f7b47b6
minor simplifications
killoctal Jul 12, 2016
b697f9c
macro SET_TEST_PARAMETER_LISTENER(Type, Name, ListenerPtr, SetUpBody)
killoctal Jul 12, 2016
ebe11e5
method for check if a parameter is ignored
killoctal Jul 22, 2016
87146c1
method rename
killoctal Jul 28, 2016
4543b15
added possibility to set auto or force local/global ignore
killoctal Jul 28, 2016
672b17b
added feature ignore index by parameter name
killoctal Jul 28, 2016
0f7dd82
created tests
killoctal Jul 28, 2016
57cc963
simplification: added SuitePredicate::addAll
killoctal Jul 28, 2016
c077a46
cleaned params argument and now mandatory param "--test"
killoctal Jul 28, 2016
c91ff62
analyze ignore by array name
killoctal Jul 28, 2016
923cd55
added tests
killoctal Jul 28, 2016
62378a6
added argument "--ignoreparam" (ex: --ignoreparam pzToto[0,2,6])
killoctal Jul 28, 2016
924c8ed
added comment about how to use commands
killoctal Jul 28, 2016
16e0dc2
fixed comment
killoctal Jul 28, 2016
69ccda4
generalization
killoctal Jul 28, 2016
21b1a59
specify "--test" is optional
killoctal Aug 22, 2016
a77b0c7
removed non pertinant and problematic condition
killoctal Aug 24, 2016
2647991
Merge branch 'master' into ParameterizedSuite
killoctal Aug 25, 2016
b48bd98
added long/short macro
killoctal Aug 25, 2016
17d6e82
forgot to remove this test after commit a77b0c74fb3df8190c0bbc825d327…
killoctal Aug 25, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 15 additions & 15 deletions UnitTest++/Checks.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,10 @@ namespace UnitTest {

template< typename Expected, typename Actual >
void CheckArrayEqual(TestResults& results, Expected const& expected, Actual const& actual,
int const count, TestDetails const& details)
size_t const count, TestDetails const& details)
{
bool equal = true;
for (int i = 0; i < count; ++i)
for (size_t i = 0; i < count; ++i)
equal &= (expected[i] == actual[i]);

if (!equal)
Expand All @@ -69,12 +69,12 @@ namespace UnitTest {

stream << "Expected [ ";

for (int expectedIndex = 0; expectedIndex < count; ++expectedIndex)
for (size_t expectedIndex = 0; expectedIndex < count; ++expectedIndex)
stream << expected[expectedIndex] << " ";

stream << "] but was [ ";

for (int actualIndex = 0; actualIndex < count; ++actualIndex)
for (size_t actualIndex = 0; actualIndex < count; ++actualIndex)
stream << actual[actualIndex] << " ";

stream << "]";
Expand All @@ -84,17 +84,17 @@ namespace UnitTest {
}

template< typename Expected, typename Actual, typename Tolerance >
bool ArrayAreClose(Expected const& expected, Actual const& actual, int const count, Tolerance const& tolerance)
bool ArrayAreClose(Expected const& expected, Actual const& actual, size_t const count, Tolerance const& tolerance)
{
bool equal = true;
for (int i = 0; i < count; ++i)
for (size_t i = 0; i < count; ++i)
equal &= AreClose(expected[i], actual[i], tolerance);
return equal;
}

template< typename Expected, typename Actual, typename Tolerance >
void CheckArrayClose(TestResults& results, Expected const& expected, Actual const& actual,
int const count, Tolerance const& tolerance, TestDetails const& details)
size_t const count, Tolerance const& tolerance, TestDetails const& details)
{
bool equal = ArrayAreClose(expected, actual, count, tolerance);

Expand All @@ -103,11 +103,11 @@ namespace UnitTest {
UnitTest::MemoryOutStream stream;

stream << "Expected [ ";
for (int expectedIndex = 0; expectedIndex < count; ++expectedIndex)
for (size_t expectedIndex = 0; expectedIndex < count; ++expectedIndex)
stream << expected[expectedIndex] << " ";
stream << "] +/- " << tolerance << " but was [ ";

for (int actualIndex = 0; actualIndex < count; ++actualIndex)
for (size_t actualIndex = 0; actualIndex < count; ++actualIndex)
stream << actual[actualIndex] << " ";
stream << "]";

Expand All @@ -117,10 +117,10 @@ namespace UnitTest {

template< typename Expected, typename Actual, typename Tolerance >
void CheckArray2DClose(TestResults& results, Expected const& expected, Actual const& actual,
int const rows, int const columns, Tolerance const& tolerance, TestDetails const& details)
size_t const rows, size_t const columns, Tolerance const& tolerance, TestDetails const& details)
{
bool equal = true;
for (int i = 0; i < rows; ++i)
for (size_t i = 0; i < rows; ++i)
equal &= ArrayAreClose(expected[i], actual[i], columns, tolerance);

if (!equal)
Expand All @@ -129,20 +129,20 @@ namespace UnitTest {

stream << "Expected [ ";

for (int expectedRow = 0; expectedRow < rows; ++expectedRow)
for (size_t expectedRow = 0; expectedRow < rows; ++expectedRow)
{
stream << "[ ";
for (int expectedColumn = 0; expectedColumn < columns; ++expectedColumn)
for (size_t expectedColumn = 0; expectedColumn < columns; ++expectedColumn)
stream << expected[expectedRow][expectedColumn] << " ";
stream << "] ";
}

stream << "] +/- " << tolerance << " but was [ ";

for (int actualRow = 0; actualRow < rows; ++actualRow)
for (size_t actualRow = 0; actualRow < rows; ++actualRow)
{
stream << "[ ";
for (int actualColumn = 0; actualColumn < columns; ++actualColumn)
for (size_t actualColumn = 0; actualColumn < columns; ++actualColumn)
stream << actual[actualRow][actualColumn] << " ";
stream << "] ";
}
Expand Down
9 changes: 8 additions & 1 deletion UnitTest++/ExecuteTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include "AssertException.h"
#include "RequiredCheckException.h"
#include "CurrentTest.h"
#include "ParameterizedManager.h"

#ifdef UNITTEST_NO_EXCEPTIONS
#include "ReportAssertImpl.h"
Expand All @@ -20,12 +21,16 @@

namespace UnitTest {

//TODO remove template and parameter "templateIsTest", replace with an interface
template< typename T >
void ExecuteTest(T& testObject, TestDetails const& details, bool isMockTest)
void ExecuteTest(T& testObject, TestDetails const& details, bool isMockTest, bool templateIsTest)
{
if (isMockTest == false)
CurrentTest::Details() = &details;

if (templateIsTest)
ParameterizedManager::getInstance().beginExecute(&details);

#ifdef UNITTEST_NO_EXCEPTIONS
if (UNITTEST_SET_ASSERT_JUMP_TARGET() == 0)
{
Expand Down Expand Up @@ -54,6 +59,8 @@ namespace UnitTest {
#ifdef UNITTEST_NO_EXCEPTIONS
}
#endif
if (templateIsTest)
ParameterizedManager::getInstance().endExecute(&details);
}

}
Expand Down
43 changes: 43 additions & 0 deletions UnitTest++/ParameterizedMacros.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#ifndef UNITTEST_PARAMETERIZEDMACROS_H
#define UNITTEST_PARAMETERIZEDMACROS_H

#include "TestParameter.h"


#define UNITTEST_SET_TEST_PARAMETER_LISTENER(Type, Name, ListenerPtr, SetUpBody) \
class ParameterizedCreator##Name \
{ \
public: \
ParameterizedCreator##Name() : globalInstance(getGlobalInstance()) {} \
UnitTest::TestParameter<Type> & globalInstance; \
private: \
static UnitTest::TestParameter<Type> & getGlobalInstance() \
{ \
static UnitTest::TestParameter<Type> instance(#Name, create(), ListenerPtr); \
return instance; \
} \
static vector<Type> create() { vector<Type> values; SetUpBody return values; } \
} static parameterizedCreator##Name##Instance; \
\
static UnitTest::TestParameter<Type> & Name(parameterizedCreator##Name##Instance.globalInstance)


#define UNITTEST_SET_TEST_PARAMETER(Type, Name, SetUpBody) \
UNITTEST_SET_TEST_PARAMETER_LISTENER(Type, Name, nullptr, SetUpBody)


#ifndef UNITTEST_DISABLE_SHORT_MACROS
#ifdef SET_TEST_PARAMETER_LISTENER
#error SET_TEST_PARAMETER_LISTENER already defined, re-configure with UNITTEST_ENABLE_SHORT_MACROS set to 0 and use UNITTEST_SET_TEST_PARAMETER_LISTENER instead
#else
#define SET_TEST_PARAMETER_LISTENER UNITTEST_SET_TEST_PARAMETER_LISTENER
#endif

#ifdef SET_TEST_PARAMETER
#error SET_TEST_PARAMETER already defined, re-configure with UNITTEST_ENABLE_SHORT_MACROS set to 0 and use UNITTEST_SET_TEST_PARAMETER instead
#else
#define SET_TEST_PARAMETER UNITTEST_SET_TEST_PARAMETER
#endif
#endif

#endif
Loading