Skip to content

Commit

Permalink
Update unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
uweseimet committed Dec 12, 2023
1 parent 4cdd4e4 commit 49dab8a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
1 change: 0 additions & 1 deletion cpp/test/mocks.h
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,6 @@ class MockScsiController : public ScsiController
{
}
~MockScsiController() override = default;

};

class MockDevice : public Device
Expand Down
15 changes: 15 additions & 0 deletions cpp/test/scsi_controller_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ TEST(ScsiControllerTest, GetInitiatorId)

auto bus = make_shared<NiceMock<MockBus>>();
MockScsiController controller(bus, 0);
auto device = make_shared<MockPrimaryDevice>(0);

controller.AddDevice(device);

controller.Process(ID);
EXPECT_EQ(ID, controller.GetInitiatorId());
Expand All @@ -28,7 +31,10 @@ TEST(ScsiControllerTest, Process)
{
auto bus = make_shared<NiceMock<MockBus>>();
MockScsiController controller(bus, 0);
auto device = make_shared<MockPrimaryDevice>(0);

controller.Init();
controller.AddDevice(device);

controller.SetPhase(phase_t::reserved);
ON_CALL(*bus, GetRST).WillByDefault(Return(true));
Expand Down Expand Up @@ -84,6 +90,9 @@ TEST(ScsiControllerTest, Selection)
{
auto bus = make_shared<NiceMock<MockBus>>();
auto controller = make_shared<MockScsiController>(bus, 0);
auto device = make_shared<MockPrimaryDevice>(0);

controller->AddDevice(device);

controller->SetPhase(phase_t::selection);
ON_CALL(*bus, GetSEL).WillByDefault(Return(true));
Expand Down Expand Up @@ -130,6 +139,9 @@ TEST(ScsiControllerTest, Command)
{
auto bus = make_shared<NiceMock<MockBus>>();
MockScsiController controller(bus, 0);
auto device = make_shared<MockPrimaryDevice>(0);

controller.AddDevice(device);

controller.SetPhase(phase_t::command);
EXPECT_CALL(controller, Status).Times(2);
Expand Down Expand Up @@ -226,6 +238,9 @@ TEST(ScsiControllerTest, Error)
{
auto bus = make_shared<NiceMock<MockBus>>();
MockScsiController controller(bus, 0);
auto device = make_shared<MockPrimaryDevice>(0);

controller.AddDevice(device);

ON_CALL(*bus, GetRST).WillByDefault(Return(true));
controller.SetPhase(phase_t::reserved);
Expand Down

0 comments on commit 49dab8a

Please sign in to comment.