Skip to content

Commit 4b50273

Browse files
add test for custom events in the published event recorder
1 parent c0b17ee commit 4b50273

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

cpputest-for-qpcpp-lib/tests/publishedEventRecorderTests.cpp

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,19 @@
2828

2929
using namespace cms::test;
3030

31+
namespace {
32+
33+
struct TestEvent : QP::QEvt
34+
{
35+
explicit constexpr TestEvent(QP::QSignal const s, int value) noexcept
36+
: QP::QEvt(s),
37+
testValue(value)
38+
{}
39+
int testValue;
40+
};
41+
42+
}
43+
3144
TEST_GROUP(PublishedEventRecorderTests) {
3245
static constexpr enum_t TEST1_PUBLISH_SIG = QP::Q_USER_SIG + 1;
3346
static constexpr enum_t TEST2_PUBLISH_SIG = TEST1_PUBLISH_SIG + 1;
@@ -112,3 +125,14 @@ TEST(PublishedEventRecorderTests,
112125
auto event = mUnderTest->getRecordedEvent<QP::QEvt>();
113126
CHECK_TRUE(event == nullptr);
114127
}
128+
129+
TEST(PublishedEventRecorderTests, can_record_custom_event)
130+
{
131+
static const TestEvent testEvent(TEST1_PUBLISH_SIG, 5);
132+
qf_ctrl::PublishAndProcess(&testEvent);
133+
CHECK_TRUE(mUnderTest->isAnyEventRecorded());
134+
auto event = mUnderTest->getRecordedEvent<TestEvent>();
135+
CHECK_TRUE(event != nullptr);
136+
CHECK_EQUAL(TEST1_PUBLISH_SIG, event->sig);
137+
CHECK_EQUAL(5, event->testValue);
138+
}

0 commit comments

Comments
 (0)