Skip to content

Commit

Permalink
Add KnitterMock::quit()
Browse files Browse the repository at this point in the history
  • Loading branch information
t0mpr1c3 committed Mar 13, 2024
1 parent 847c13c commit e868009
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 8 deletions.
7 changes: 6 additions & 1 deletion test/mocks/knitter_mock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,5 +109,10 @@ void Knitter::setLastLine() {

void Knitter::setMachineType(Machine_t machineType) {
assert(gKnitterMock != nullptr);
return gKnitterMock->setMachineType(machineType);
gKnitterMock->setMachineType(machineType);
}

void Knitter::quit() const {
assert(gKnitterMock != nullptr);
gKnitterMock->quit();
}
1 change: 1 addition & 0 deletions test/mocks/knitter_mock.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ class KnitterMock : public KnitterInterface {
MOCK_METHOD1(setNextLine, bool(uint8_t lineNumber));
MOCK_METHOD0(setLastLine, void());
MOCK_METHOD1(setMachineType, void(Machine_t));
MOCK_CONST_METHOD0(quit, void());
};

KnitterMock *knitterMockInstance();
Expand Down
3 changes: 2 additions & 1 deletion test/test_com.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,8 @@ TEST_F(ComTest, test_stopCmd) {
com->onPacketReceived(buffer, sizeof(buffer));
}

TEST_F(ComTest, test_quitCmd) {
TEST_F(ComTest, test_quitCmd_test) {
fsm->setState(OpState::test);
uint8_t buffer[] = {static_cast<uint8_t>(AYAB_API::quitCmd)};
EXPECT_CALL(*knitterMock, setUpInterrupt);
EXPECT_CALL(*fsmMock, setState(OpState::init));
Expand Down
6 changes: 2 additions & 4 deletions test/test_knitter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -737,9 +737,7 @@ TEST_F(KnitterTest, test_fsm_init_LR) {

TEST_F(KnitterTest, test_quit) {
get_to_knit(Machine_t::Kh910);
EXPECT_CALL(*fsmMock, setState(OpState::init));
//ASSERT_EQ(fsm->getState(), OpState::knit);
knitter->quit();

// test expectations without destroying instance
ASSERT_TRUE(Mock::VerifyAndClear(fsmMock));
ASSERT_EQ(fsm->getState(), OpState::init);
}
5 changes: 3 additions & 2 deletions test/test_tester.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -194,12 +194,13 @@ TEST_F(TesterTest, test_autoTestCmd) {
}

TEST_F(TesterTest, test_quitCmd) {
EXPECT_CALL(*knitterMock, setUpInterrupt);
expect_startTest(0);
//EXPECT_CALL(*knitterMock, setUpInterrupt);
EXPECT_CALL(*fsmMock, setState(OpState::init));
tester->quitCmd();

// test expectations without destroying instance
ASSERT_TRUE(Mock::VerifyAndClear(knitterMock));
//ASSERT_TRUE(Mock::VerifyAndClear(knitterMock));
ASSERT_TRUE(Mock::VerifyAndClear(fsmMock));
}

Expand Down

0 comments on commit e868009

Please sign in to comment.