Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
t0mpr1c3 committed Sep 13, 2023
1 parent 2f228dd commit 521a5ac
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 15 deletions.
2 changes: 1 addition & 1 deletion test/test_boards.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,5 +55,5 @@ KnitterInterface *GlobalKnitter::m_instance = knitter;

int main(int argc, char *argv[]) {
::testing::InitGoogleMock(&argc, argv);
return RUN_ALL_TESTS();
return RUN_ALL_TESTS();
}
6 changes: 0 additions & 6 deletions test/test_com.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
#include <encoders.h>

#include <fsm_mock.h>
#include <beeper_mock.h>
#include <knitter_mock.h>

using ::testing::_;
Expand All @@ -37,7 +36,6 @@ using ::testing::Return;

extern Com *com;

extern BeeperMock *beeper;
extern FsmMock *fsm;
extern KnitterMock *knitter;

Expand All @@ -48,14 +46,12 @@ class ComTest : public ::testing::Test {
serialMock = serialMockInstance();

// pointer to global instance
beeperMock = beeper;
fsmMock = fsm;
knitterMock = knitter;

// The global instance does not get destroyed at the end of each test.
// Ordinarily the mock instance would be local and such behaviour would
// cause a memory leak. We must notify the test that this is not the case.
Mock::AllowLeak(beeperMock);
Mock::AllowLeak(fsmMock);
Mock::AllowLeak(knitterMock);

Expand All @@ -69,7 +65,6 @@ class ComTest : public ::testing::Test {
}

ArduinoMock *arduinoMock;
BeeperMock *beeperMock;
FsmMock *fsmMock;
KnitterMock *knitterMock;
SerialMock *serialMock;
Expand Down Expand Up @@ -211,7 +206,6 @@ TEST_F(ComTest, test_sendCmd) {

TEST_F(ComTest, test_beepCmd) {
uint8_t buffer[] = {beepCmd_msgid};
EXPECT_CALL(*beeperMock, ready()).Times(1);
EXPECT_CALL(*arduinoMock, analogWrite(PIEZO_PIN, _)).Times(AtLeast(1));
expected_write_onPacketReceived(buffer, sizeof(buffer), true);
}
Expand Down
9 changes: 1 addition & 8 deletions test/test_tester.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,8 @@

#include <gtest/gtest.h>

#include <com.h>
#include <tester.h>

#include <beeper_mock.h>
#include <fsm_mock.h>
#include <knitter_mock.h>

Expand All @@ -38,7 +36,6 @@ using ::testing::Return;

extern Tester *tester;

extern BeeperMock *beeper;
extern FsmMock *fsm;
extern KnitterMock *knitter;

Expand All @@ -50,14 +47,12 @@ class TesterTest : public ::testing::Test {
// serialCommandMock = serialCommandMockInstance();

// pointers to global instances
beeperMock = beeper;
fsmMock = fsm;
knitterMock = knitter;

// The global instances do not get destroyed at the end of each test.
// Ordinarily the mock instance would be local and such behaviour would
// cause a memory leak. We must notify the test that this is not the case.
Mock::AllowLeak(beeperMock);
Mock::AllowLeak(fsmMock);
Mock::AllowLeak(knitterMock);
}
Expand All @@ -68,10 +63,9 @@ class TesterTest : public ::testing::Test {
}

ArduinoMock *arduinoMock;
SerialMock *serialMock;
BeeperMock *beeperMock;
FsmMock *fsmMock;
KnitterMock *knitterMock;
SerialMock *serialMock;

void expect_startTest(unsigned long t) {
EXPECT_CALL(*fsmMock, getState).WillOnce(Return(OpState::ready));
Expand Down Expand Up @@ -123,7 +117,6 @@ TEST_F(TesterTest, test_sendCmd) {

TEST_F(TesterTest, test_beepCmd) {
expect_write(true);
EXPECT_CALL(*beeperMock, ready()).Times(1);
EXPECT_CALL(*arduinoMock, analogWrite(PIEZO_PIN, _)).Times(AtLeast(1));
tester->beepCmd();
}
Expand Down

0 comments on commit 521a5ac

Please sign in to comment.