-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
pull in qassert-meta, update dummy active object same as qpc version …
…and other related changes to match QP/C version of this library.
- Loading branch information
1 parent
d023f83
commit 8a67a7a
Showing
11 changed files
with
229 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
70 changes: 70 additions & 0 deletions
70
cpputest-for-qpcpp-lib/tests/cms_dummy_active_object_tests.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
#include "cmsDummyActiveObject.hpp" | ||
#include "cms_cpputest_qf_ctrl.hpp" | ||
#include "qpcpp.hpp" | ||
#include <memory> | ||
|
||
//cpputest header include must always be last | ||
#include "CppUTest/TestHarness.h" | ||
|
||
using namespace cms; | ||
using namespace cms::test; | ||
|
||
TEST_GROUP(dummy_ao_tests) | ||
{ | ||
void setup() final | ||
{ | ||
qf_ctrl::Setup(QP::Q_USER_SIG, 100); | ||
} | ||
|
||
void teardown() final | ||
{ | ||
qf_ctrl::Teardown(); | ||
} | ||
}; | ||
|
||
TEST(dummy_ao_tests, dummy_ao_provides_callback_by_default) | ||
{ | ||
auto dummy = CreateAndStartDummyActiveObject(); | ||
CHECK_TRUE(dummy->isRecorderEmpty()); | ||
CHECK_FALSE(dummy->isAnyEventRecorded()); | ||
|
||
static constexpr enum_t TEST1_SIG = QP::Q_USER_SIG + 1; | ||
enum_t capturedSig = -1; | ||
dummy->SetPostedEventHandler([&](const QP::QEvt* e){ | ||
capturedSig = e->sig; | ||
}); | ||
qf_ctrl::PostAndProcess<TEST1_SIG>(dummy.get()); | ||
CHECK_EQUAL(TEST1_SIG, capturedSig); | ||
CHECK_FALSE(dummy->isAnyEventRecorded()); //still false, internal recorder not in use here. | ||
CHECK_TRUE(dummy->isRecorderEmpty()); | ||
} | ||
|
||
TEST(dummy_ao_tests, dummy_ao_provides_recorder_option) | ||
{ | ||
auto dummy = CreateAndStartDummyActiveObject( | ||
DefaultDummyActiveObject::EventBehavior::RECORDER); | ||
|
||
static constexpr enum_t TEST1_SIG = QP::Q_USER_SIG + 1; | ||
static constexpr enum_t TEST2_SIG = TEST1_SIG + 1; | ||
|
||
CHECK_TRUE(dummy->isRecorderEmpty()); | ||
|
||
enum_t capturedSig = -1; | ||
|
||
//this should actually do nothing, since this AO is using its internal | ||
//recorder | ||
dummy->SetPostedEventHandler([&](const QP::QEvt* e){ | ||
capturedSig = e->sig; | ||
}); | ||
qf_ctrl::PostAndProcess<TEST1_SIG>(dummy.get()); | ||
qf_ctrl::PostAndProcess<TEST2_SIG>(dummy.get()); | ||
CHECK_EQUAL(-1, capturedSig); //confirm above callback did NOT happen | ||
|
||
CHECK_TRUE(dummy->isAnyEventRecorded()); | ||
auto recordedEvent1 = dummy->getRecordedEvent<QP::QEvt>(); | ||
CHECK_TRUE(recordedEvent1 != nullptr); | ||
CHECK_EQUAL(TEST1_SIG, recordedEvent1->sig); | ||
|
||
CHECK_TRUE(dummy->isAnyEventRecorded()); | ||
CHECK_TRUE(dummy->isSignalRecorded(TEST2_SIG)); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters