Skip to content

Commit

Permalink
nci unit testing
Browse files Browse the repository at this point in the history
  • Loading branch information
Strooom committed Oct 29, 2024
1 parent cc4b267 commit 0b05ca5
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
4 changes: 2 additions & 2 deletions platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,10 @@ test_filter =
;generic/test_logging
;generic/test_singletimer
;generic/test_intervaltimer
;generic/test_nci
generic/test_nci
;generic/test_ncistate
;generic/test_ncipacket
generic/test_pn7160interface
;generic/test_pn7160interface

debug_test = generic/test_tag

Expand Down
20 changes: 20 additions & 0 deletions test/generic/test_nci/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,36 @@ void test_check_status() {
TEST_ASSERT_TRUE(nci::checkMessageStatus(0x00));
}

void test_state_machine() {
nci::reset();
nci::run();
TEST_ASSERT_EQUAL(nciState::venResetActive, nci::getState());
singleTimer::mockMillis += 5;
nci::run();
TEST_ASSERT_EQUAL(nciState::waitForResetDone, nci::getState());
singleTimer::mockMillis += 5;
nci::run();
TEST_ASSERT_EQUAL(nciState::waitForCoreResetResponse, nci::getState());
}

void test_dummy() {
nci::moveState(nciState::boot);
nci::getMessage();
nci::checkMessageLength(0);
nci::getMessageType(nci::rxBuffer);
nci::getGroupIdentifier(nci::rxBuffer);
nci::getOpcodeIdentifier(nci::rxBuffer);
nci::getMessageId(nci::rxBuffer);
nci::timeoutError();
nci::unexpectedMessageError();
}

int main(int argc, char **argv) {
UNITY_BEGIN();
RUN_TEST(test_initialize);
RUN_TEST(test_reset);
RUN_TEST(test_check_status);
RUN_TEST(test_state_machine);
RUN_TEST(test_dummy);
UNITY_END();
}

0 comments on commit 0b05ca5

Please sign in to comment.