-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add PostAndProcess helper convenience methods
- Loading branch information
1 parent
06d62a7
commit 566fc02
Showing
3 changed files
with
96 additions
and
0 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
74 changes: 74 additions & 0 deletions
74
cpputest-for-qpc-lib/tests/cms_cpputest_qf_ctrl_post_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,74 @@ | ||
//// @brief Tests for the qf_ctrl post related functions for the QF cpputest port. | ||
/// @ingroup | ||
/// @cond | ||
///*************************************************************************** | ||
/// | ||
/// Copyright (C) 2024 Matthew Eshleman. All rights reserved. | ||
/// | ||
/// This program is open source software: you can redistribute it and/or | ||
/// modify it under the terms of the GNU General Public License as published | ||
/// by the Free Software Foundation, either version 3 of the License, or | ||
/// (at your option) any later version. | ||
/// | ||
/// Alternatively, upon written permission from Matthew Eshleman, this program | ||
/// may be distributed and modified under the terms of a Commercial | ||
/// License. For further details, see the Contact Information below. | ||
/// | ||
/// Contact Information: | ||
/// Matthew Eshleman | ||
/// https://covemountainsoftware.com | ||
/// [email protected] | ||
///*************************************************************************** | ||
/// @endcond | ||
|
||
#include "cmsDummyActiveObject.hpp" | ||
#include "cms_cpputest_qf_ctrl.hpp" | ||
#include "qpc.h" | ||
|
||
//cpputest header include must always be last | ||
#include "CppUTest/TestHarness.h" | ||
|
||
using namespace cms::test; | ||
|
||
TEST_GROUP(qf_ctrl_post_tests) | ||
{ | ||
cms::DefaultDummyActiveObject* mDummy = nullptr; | ||
|
||
void setup() final | ||
{ | ||
qf_ctrl::Setup(Q_USER_SIG, 100); | ||
mDummy = new cms::DefaultDummyActiveObject(); | ||
mDummy->dummyStart(); | ||
} | ||
|
||
void teardown() final | ||
{ | ||
delete mDummy; | ||
cms::test::qf_ctrl::Teardown(); | ||
} | ||
}; | ||
|
||
TEST(qf_ctrl_post_tests, | ||
provides_a_post_and_process_helper_func_with_trivial_signal_enum) | ||
{ | ||
static constexpr enum_t TEST1_SIG = Q_USER_SIG + 1; | ||
enum_t capturedSig = -1; | ||
mDummy->SetPostedEventHandler([&](const QEvt* e){ | ||
capturedSig = e->sig; | ||
}); | ||
qf_ctrl::PostAndProcess<TEST1_SIG>(mDummy->getQActive()); | ||
CHECK_EQUAL(TEST1_SIG, capturedSig); | ||
} | ||
|
||
TEST(qf_ctrl_post_tests, | ||
provides_a_post_and_process_helper_func) | ||
{ | ||
static constexpr enum_t TEST2_SIG = Q_USER_SIG + 111; | ||
static const QEvt testEvent = QEVT_INITIALIZER(TEST2_SIG); | ||
enum_t capturedSig = -1; | ||
mDummy->SetPostedEventHandler([&](const QEvt* e){ | ||
capturedSig = e->sig; | ||
}); | ||
qf_ctrl::PostAndProcess(&testEvent, mDummy->getQActive()); | ||
CHECK_EQUAL(TEST2_SIG, capturedSig); | ||
} |