SASI code removal, error handling update, bug fixes, code cleanup (#806)
Summary ov most important changes triggered by the SASI code removal:
- Removed the SASI controller code
- New controller management. There is a new controller base class AbstractController and a class ControllerManager managing the controller lifecycle. The lifecycle management was removed from rasci.cpp and is covered by unit tests.
- New device management. The DeviceFactory manages the device lifecycle instead of rascsi.cpp. The new code is covered by unit tests.
- The lifecycle managment uses C++ collections with variable size instead of arrays with hard-coded sizes.
- The ScsiController method contains most of what was previously contained in scsidev_ctrl.cpp plus the code from sasidev_ctrl.cpp that was relevant for SCSI.
- scsi_command_util contains helper methods used for identical SCSI command implementations of more than one device
- Devices know their controllers, so that the controller instance does not need to be passed to each SCSI command. This change helps to decouple the devices from the controller. The phase_handler interface is also part of this decoupling.
- Use scsi_command_exception for propagating SCSI command execution errors, This resolves issues with the previous error handling, which was based on return values and often on magic numbers.
- Removed legacy SCSI error codes, all errors are now encoded by sense_key::, asc:: and status::.
- Fixed various warnings reported with -Wextra, -Weffc++ and -Wpedantic.
- Use constructor member initialization lists (recommended for ISO C++)
- Consistently use new/delete instead of malloc/free (recommended for ISO C++), resulting in better type safety and error handling
- Replaced variable sized arrays on the stack (violates ISO C++ and can cause a stack overflow)
- Replaced NULL by nullptr (recommended for C++), resulting in better type safety
- Use more const member functions in order to avoid side effects
- The format device page can now also be changed for hard disk drives (Fujitsu M2624S supports this, for instance), not just for MOs.
- Better encapsulation, updated access specifiers in many places
- Removed unused methods and method arguments
- Fixed a number of TODOs
- Added/updated unit tests for a lot of non-legacy classes
- Makefile support for creating HTML coverage reports with lcov/genhtml
2022-09-03 14:53:53 +00:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
2022-12-05 17:58:23 +00:00
|
|
|
// SCSI Target Emulator PiSCSI
|
SASI code removal, error handling update, bug fixes, code cleanup (#806)
Summary ov most important changes triggered by the SASI code removal:
- Removed the SASI controller code
- New controller management. There is a new controller base class AbstractController and a class ControllerManager managing the controller lifecycle. The lifecycle management was removed from rasci.cpp and is covered by unit tests.
- New device management. The DeviceFactory manages the device lifecycle instead of rascsi.cpp. The new code is covered by unit tests.
- The lifecycle managment uses C++ collections with variable size instead of arrays with hard-coded sizes.
- The ScsiController method contains most of what was previously contained in scsidev_ctrl.cpp plus the code from sasidev_ctrl.cpp that was relevant for SCSI.
- scsi_command_util contains helper methods used for identical SCSI command implementations of more than one device
- Devices know their controllers, so that the controller instance does not need to be passed to each SCSI command. This change helps to decouple the devices from the controller. The phase_handler interface is also part of this decoupling.
- Use scsi_command_exception for propagating SCSI command execution errors, This resolves issues with the previous error handling, which was based on return values and often on magic numbers.
- Removed legacy SCSI error codes, all errors are now encoded by sense_key::, asc:: and status::.
- Fixed various warnings reported with -Wextra, -Weffc++ and -Wpedantic.
- Use constructor member initialization lists (recommended for ISO C++)
- Consistently use new/delete instead of malloc/free (recommended for ISO C++), resulting in better type safety and error handling
- Replaced variable sized arrays on the stack (violates ISO C++ and can cause a stack overflow)
- Replaced NULL by nullptr (recommended for C++), resulting in better type safety
- Use more const member functions in order to avoid side effects
- The format device page can now also be changed for hard disk drives (Fujitsu M2624S supports this, for instance), not just for MOs.
- Better encapsulation, updated access specifiers in many places
- Removed unused methods and method arguments
- Fixed a number of TODOs
- Added/updated unit tests for a lot of non-legacy classes
- Makefile support for creating HTML coverage reports with lcov/genhtml
2022-09-03 14:53:53 +00:00
|
|
|
// for Raspberry Pi
|
|
|
|
//
|
2023-10-15 06:38:15 +00:00
|
|
|
// Copyright (C) 2022-2023 Uwe Seimet
|
SASI code removal, error handling update, bug fixes, code cleanup (#806)
Summary ov most important changes triggered by the SASI code removal:
- Removed the SASI controller code
- New controller management. There is a new controller base class AbstractController and a class ControllerManager managing the controller lifecycle. The lifecycle management was removed from rasci.cpp and is covered by unit tests.
- New device management. The DeviceFactory manages the device lifecycle instead of rascsi.cpp. The new code is covered by unit tests.
- The lifecycle managment uses C++ collections with variable size instead of arrays with hard-coded sizes.
- The ScsiController method contains most of what was previously contained in scsidev_ctrl.cpp plus the code from sasidev_ctrl.cpp that was relevant for SCSI.
- scsi_command_util contains helper methods used for identical SCSI command implementations of more than one device
- Devices know their controllers, so that the controller instance does not need to be passed to each SCSI command. This change helps to decouple the devices from the controller. The phase_handler interface is also part of this decoupling.
- Use scsi_command_exception for propagating SCSI command execution errors, This resolves issues with the previous error handling, which was based on return values and often on magic numbers.
- Removed legacy SCSI error codes, all errors are now encoded by sense_key::, asc:: and status::.
- Fixed various warnings reported with -Wextra, -Weffc++ and -Wpedantic.
- Use constructor member initialization lists (recommended for ISO C++)
- Consistently use new/delete instead of malloc/free (recommended for ISO C++), resulting in better type safety and error handling
- Replaced variable sized arrays on the stack (violates ISO C++ and can cause a stack overflow)
- Replaced NULL by nullptr (recommended for C++), resulting in better type safety
- Use more const member functions in order to avoid side effects
- The format device page can now also be changed for hard disk drives (Fujitsu M2624S supports this, for instance), not just for MOs.
- Better encapsulation, updated access specifiers in many places
- Removed unused methods and method arguments
- Fixed a number of TODOs
- Added/updated unit tests for a lot of non-legacy classes
- Makefile support for creating HTML coverage reports with lcov/genhtml
2022-09-03 14:53:53 +00:00
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2022-10-04 15:23:42 +00:00
|
|
|
#include "mocks.h"
|
2022-12-05 17:58:23 +00:00
|
|
|
#include "shared/piscsi_exceptions.h"
|
SASI code removal, error handling update, bug fixes, code cleanup (#806)
Summary ov most important changes triggered by the SASI code removal:
- Removed the SASI controller code
- New controller management. There is a new controller base class AbstractController and a class ControllerManager managing the controller lifecycle. The lifecycle management was removed from rasci.cpp and is covered by unit tests.
- New device management. The DeviceFactory manages the device lifecycle instead of rascsi.cpp. The new code is covered by unit tests.
- The lifecycle managment uses C++ collections with variable size instead of arrays with hard-coded sizes.
- The ScsiController method contains most of what was previously contained in scsidev_ctrl.cpp plus the code from sasidev_ctrl.cpp that was relevant for SCSI.
- scsi_command_util contains helper methods used for identical SCSI command implementations of more than one device
- Devices know their controllers, so that the controller instance does not need to be passed to each SCSI command. This change helps to decouple the devices from the controller. The phase_handler interface is also part of this decoupling.
- Use scsi_command_exception for propagating SCSI command execution errors, This resolves issues with the previous error handling, which was based on return values and often on magic numbers.
- Removed legacy SCSI error codes, all errors are now encoded by sense_key::, asc:: and status::.
- Fixed various warnings reported with -Wextra, -Weffc++ and -Wpedantic.
- Use constructor member initialization lists (recommended for ISO C++)
- Consistently use new/delete instead of malloc/free (recommended for ISO C++), resulting in better type safety and error handling
- Replaced variable sized arrays on the stack (violates ISO C++ and can cause a stack overflow)
- Replaced NULL by nullptr (recommended for C++), resulting in better type safety
- Use more const member functions in order to avoid side effects
- The format device page can now also be changed for hard disk drives (Fujitsu M2624S supports this, for instance), not just for MOs.
- Better encapsulation, updated access specifiers in many places
- Removed unused methods and method arguments
- Fixed a number of TODOs
- Added/updated unit tests for a lot of non-legacy classes
- Makefile support for creating HTML coverage reports with lcov/genhtml
2022-09-03 14:53:53 +00:00
|
|
|
#include "controllers/abstract_controller.h"
|
|
|
|
|
2022-10-04 15:23:42 +00:00
|
|
|
using namespace scsi_defs;
|
|
|
|
|
2022-10-23 19:51:39 +00:00
|
|
|
TEST(AbstractControllerTest, AllocateCmd)
|
|
|
|
{
|
2023-10-15 06:38:15 +00:00
|
|
|
MockAbstractController controller;
|
2022-10-23 19:51:39 +00:00
|
|
|
|
|
|
|
EXPECT_EQ(16, controller.GetCmd().size());
|
|
|
|
controller.AllocateCmd(1234);
|
|
|
|
EXPECT_EQ(1234, controller.GetCmd().size());
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST(AbstractControllerTest, AllocateBuffer)
|
|
|
|
{
|
2023-10-15 06:38:15 +00:00
|
|
|
MockAbstractController controller;
|
2022-10-23 19:51:39 +00:00
|
|
|
|
|
|
|
controller.AllocateBuffer(1);
|
|
|
|
EXPECT_LE(1, controller.GetBuffer().size());
|
|
|
|
controller.AllocateBuffer(10000);
|
|
|
|
EXPECT_LE(10000, controller.GetBuffer().size());
|
|
|
|
}
|
|
|
|
|
2022-10-01 15:56:06 +00:00
|
|
|
TEST(AbstractControllerTest, Reset)
|
|
|
|
{
|
2022-11-04 07:22:32 +00:00
|
|
|
auto bus = make_shared<MockBus>();
|
2023-10-15 06:38:15 +00:00
|
|
|
auto controller = make_shared<MockAbstractController>(bus, 0);
|
2022-10-04 15:23:42 +00:00
|
|
|
auto device = make_shared<MockPrimaryDevice>(0);
|
|
|
|
|
2022-11-04 07:22:32 +00:00
|
|
|
controller->AddDevice(device);
|
2022-10-01 15:56:06 +00:00
|
|
|
|
2022-12-03 04:20:27 +00:00
|
|
|
controller->SetPhase(phase_t::status);
|
|
|
|
EXPECT_EQ(phase_t::status, controller->GetPhase());
|
2023-10-15 06:38:15 +00:00
|
|
|
EXPECT_CALL(*bus, Reset());
|
2022-11-04 07:22:32 +00:00
|
|
|
controller->Reset();
|
|
|
|
EXPECT_TRUE(controller->IsBusFree());
|
2023-10-15 06:38:15 +00:00
|
|
|
EXPECT_EQ(status::good, controller->GetStatus());
|
2022-11-04 07:22:32 +00:00
|
|
|
EXPECT_EQ(0, controller->GetLength());
|
2022-10-01 15:56:06 +00:00
|
|
|
}
|
|
|
|
|
2022-11-02 14:36:19 +00:00
|
|
|
TEST(AbstractControllerTest, Next)
|
|
|
|
{
|
2023-10-15 06:38:15 +00:00
|
|
|
MockAbstractController controller;
|
2022-11-02 14:36:19 +00:00
|
|
|
|
|
|
|
controller.SetNext(0x1234);
|
|
|
|
EXPECT_EQ(0x1234, controller.GetNext());
|
|
|
|
controller.IncrementNext();
|
|
|
|
EXPECT_EQ(0x1235, controller.GetNext());
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST(AbstractControllerTest, Message)
|
|
|
|
{
|
2023-10-15 06:38:15 +00:00
|
|
|
MockAbstractController controller;
|
2022-11-02 14:36:19 +00:00
|
|
|
|
|
|
|
controller.SetMessage(0x12);
|
|
|
|
EXPECT_EQ(0x12, controller.GetMessage());
|
|
|
|
}
|
|
|
|
|
2022-10-23 19:51:39 +00:00
|
|
|
TEST(AbstractControllerTest, ByteTransfer)
|
2022-10-01 15:56:06 +00:00
|
|
|
{
|
2023-10-15 06:38:15 +00:00
|
|
|
MockAbstractController controller;
|
2022-10-01 15:56:06 +00:00
|
|
|
|
2022-10-23 19:51:39 +00:00
|
|
|
controller.SetByteTransfer(false);
|
|
|
|
EXPECT_FALSE(controller.IsByteTransfer());
|
|
|
|
controller.SetByteTransfer(true);
|
|
|
|
EXPECT_TRUE(controller.IsByteTransfer());
|
|
|
|
}
|
|
|
|
|
2022-11-02 14:36:19 +00:00
|
|
|
TEST(AbstractControllerTest, BytesToTransfer)
|
|
|
|
{
|
2023-10-15 06:38:15 +00:00
|
|
|
MockAbstractController controller;
|
2022-11-02 14:36:19 +00:00
|
|
|
|
|
|
|
controller.SetBytesToTransfer(0x1234);
|
|
|
|
EXPECT_EQ(0x1234, controller.GetBytesToTransfer());
|
|
|
|
controller.SetByteTransfer(false);
|
|
|
|
EXPECT_EQ(0, controller.GetBytesToTransfer());
|
|
|
|
}
|
|
|
|
|
2022-10-23 19:51:39 +00:00
|
|
|
TEST(AbstractControllerTest, GetMaxLuns)
|
|
|
|
{
|
2023-10-15 06:38:15 +00:00
|
|
|
MockAbstractController controller;
|
2022-10-23 19:51:39 +00:00
|
|
|
|
|
|
|
EXPECT_EQ(32, controller.GetMaxLuns());
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST(AbstractControllerTest, Status)
|
|
|
|
{
|
2023-10-15 06:38:15 +00:00
|
|
|
MockAbstractController controller;
|
2022-10-23 19:51:39 +00:00
|
|
|
|
2023-10-15 06:38:15 +00:00
|
|
|
controller.SetStatus(status::reservation_conflict);
|
|
|
|
EXPECT_EQ(status::reservation_conflict, controller.GetStatus());
|
2022-10-01 15:56:06 +00:00
|
|
|
}
|
|
|
|
|
2022-09-25 21:49:24 +00:00
|
|
|
TEST(AbstractControllerTest, DeviceLunLifeCycle)
|
SASI code removal, error handling update, bug fixes, code cleanup (#806)
Summary ov most important changes triggered by the SASI code removal:
- Removed the SASI controller code
- New controller management. There is a new controller base class AbstractController and a class ControllerManager managing the controller lifecycle. The lifecycle management was removed from rasci.cpp and is covered by unit tests.
- New device management. The DeviceFactory manages the device lifecycle instead of rascsi.cpp. The new code is covered by unit tests.
- The lifecycle managment uses C++ collections with variable size instead of arrays with hard-coded sizes.
- The ScsiController method contains most of what was previously contained in scsidev_ctrl.cpp plus the code from sasidev_ctrl.cpp that was relevant for SCSI.
- scsi_command_util contains helper methods used for identical SCSI command implementations of more than one device
- Devices know their controllers, so that the controller instance does not need to be passed to each SCSI command. This change helps to decouple the devices from the controller. The phase_handler interface is also part of this decoupling.
- Use scsi_command_exception for propagating SCSI command execution errors, This resolves issues with the previous error handling, which was based on return values and often on magic numbers.
- Removed legacy SCSI error codes, all errors are now encoded by sense_key::, asc:: and status::.
- Fixed various warnings reported with -Wextra, -Weffc++ and -Wpedantic.
- Use constructor member initialization lists (recommended for ISO C++)
- Consistently use new/delete instead of malloc/free (recommended for ISO C++), resulting in better type safety and error handling
- Replaced variable sized arrays on the stack (violates ISO C++ and can cause a stack overflow)
- Replaced NULL by nullptr (recommended for C++), resulting in better type safety
- Use more const member functions in order to avoid side effects
- The format device page can now also be changed for hard disk drives (Fujitsu M2624S supports this, for instance), not just for MOs.
- Better encapsulation, updated access specifiers in many places
- Removed unused methods and method arguments
- Fixed a number of TODOs
- Added/updated unit tests for a lot of non-legacy classes
- Makefile support for creating HTML coverage reports with lcov/genhtml
2022-09-03 14:53:53 +00:00
|
|
|
{
|
|
|
|
const int ID = 1;
|
|
|
|
const int LUN = 4;
|
|
|
|
|
2023-10-15 06:38:15 +00:00
|
|
|
auto controller = make_shared<NiceMock<MockAbstractController>>(ID);
|
2022-10-25 00:21:40 +00:00
|
|
|
|
2022-10-04 15:23:42 +00:00
|
|
|
auto device1 = make_shared<MockPrimaryDevice>(LUN);
|
|
|
|
auto device2 = make_shared<MockPrimaryDevice>(32);
|
|
|
|
auto device3 = make_shared<MockPrimaryDevice>(-1);
|
SASI code removal, error handling update, bug fixes, code cleanup (#806)
Summary ov most important changes triggered by the SASI code removal:
- Removed the SASI controller code
- New controller management. There is a new controller base class AbstractController and a class ControllerManager managing the controller lifecycle. The lifecycle management was removed from rasci.cpp and is covered by unit tests.
- New device management. The DeviceFactory manages the device lifecycle instead of rascsi.cpp. The new code is covered by unit tests.
- The lifecycle managment uses C++ collections with variable size instead of arrays with hard-coded sizes.
- The ScsiController method contains most of what was previously contained in scsidev_ctrl.cpp plus the code from sasidev_ctrl.cpp that was relevant for SCSI.
- scsi_command_util contains helper methods used for identical SCSI command implementations of more than one device
- Devices know their controllers, so that the controller instance does not need to be passed to each SCSI command. This change helps to decouple the devices from the controller. The phase_handler interface is also part of this decoupling.
- Use scsi_command_exception for propagating SCSI command execution errors, This resolves issues with the previous error handling, which was based on return values and often on magic numbers.
- Removed legacy SCSI error codes, all errors are now encoded by sense_key::, asc:: and status::.
- Fixed various warnings reported with -Wextra, -Weffc++ and -Wpedantic.
- Use constructor member initialization lists (recommended for ISO C++)
- Consistently use new/delete instead of malloc/free (recommended for ISO C++), resulting in better type safety and error handling
- Replaced variable sized arrays on the stack (violates ISO C++ and can cause a stack overflow)
- Replaced NULL by nullptr (recommended for C++), resulting in better type safety
- Use more const member functions in order to avoid side effects
- The format device page can now also be changed for hard disk drives (Fujitsu M2624S supports this, for instance), not just for MOs.
- Better encapsulation, updated access specifiers in many places
- Removed unused methods and method arguments
- Fixed a number of TODOs
- Added/updated unit tests for a lot of non-legacy classes
- Makefile support for creating HTML coverage reports with lcov/genhtml
2022-09-03 14:53:53 +00:00
|
|
|
|
2022-11-04 07:22:32 +00:00
|
|
|
EXPECT_EQ(0, controller->GetLunCount());
|
|
|
|
EXPECT_EQ(ID, controller->GetTargetId());
|
|
|
|
EXPECT_TRUE(controller->AddDevice(device1));
|
|
|
|
EXPECT_FALSE(controller->AddDevice(device2));
|
|
|
|
EXPECT_FALSE(controller->AddDevice(device3));
|
|
|
|
EXPECT_TRUE(controller->GetLunCount() > 0);
|
|
|
|
EXPECT_TRUE(controller->HasDeviceForLun(LUN));
|
|
|
|
EXPECT_FALSE(controller->HasDeviceForLun(0));
|
|
|
|
EXPECT_NE(nullptr, controller->GetDeviceForLun(LUN));
|
|
|
|
EXPECT_EQ(nullptr, controller->GetDeviceForLun(0));
|
2023-10-15 06:38:15 +00:00
|
|
|
EXPECT_TRUE(controller->RemoveDevice(*device1));
|
2022-11-04 07:22:32 +00:00
|
|
|
EXPECT_EQ(0, controller->GetLunCount());
|
2023-10-15 06:38:15 +00:00
|
|
|
EXPECT_FALSE(controller->RemoveDevice(*device1));
|
SASI code removal, error handling update, bug fixes, code cleanup (#806)
Summary ov most important changes triggered by the SASI code removal:
- Removed the SASI controller code
- New controller management. There is a new controller base class AbstractController and a class ControllerManager managing the controller lifecycle. The lifecycle management was removed from rasci.cpp and is covered by unit tests.
- New device management. The DeviceFactory manages the device lifecycle instead of rascsi.cpp. The new code is covered by unit tests.
- The lifecycle managment uses C++ collections with variable size instead of arrays with hard-coded sizes.
- The ScsiController method contains most of what was previously contained in scsidev_ctrl.cpp plus the code from sasidev_ctrl.cpp that was relevant for SCSI.
- scsi_command_util contains helper methods used for identical SCSI command implementations of more than one device
- Devices know their controllers, so that the controller instance does not need to be passed to each SCSI command. This change helps to decouple the devices from the controller. The phase_handler interface is also part of this decoupling.
- Use scsi_command_exception for propagating SCSI command execution errors, This resolves issues with the previous error handling, which was based on return values and often on magic numbers.
- Removed legacy SCSI error codes, all errors are now encoded by sense_key::, asc:: and status::.
- Fixed various warnings reported with -Wextra, -Weffc++ and -Wpedantic.
- Use constructor member initialization lists (recommended for ISO C++)
- Consistently use new/delete instead of malloc/free (recommended for ISO C++), resulting in better type safety and error handling
- Replaced variable sized arrays on the stack (violates ISO C++ and can cause a stack overflow)
- Replaced NULL by nullptr (recommended for C++), resulting in better type safety
- Use more const member functions in order to avoid side effects
- The format device page can now also be changed for hard disk drives (Fujitsu M2624S supports this, for instance), not just for MOs.
- Better encapsulation, updated access specifiers in many places
- Removed unused methods and method arguments
- Fixed a number of TODOs
- Added/updated unit tests for a lot of non-legacy classes
- Makefile support for creating HTML coverage reports with lcov/genhtml
2022-09-03 14:53:53 +00:00
|
|
|
}
|
2022-09-25 21:49:24 +00:00
|
|
|
|
|
|
|
TEST(AbstractControllerTest, GetOpcode)
|
|
|
|
{
|
2023-10-15 06:38:15 +00:00
|
|
|
MockAbstractController controller;
|
2022-09-25 21:49:24 +00:00
|
|
|
|
2023-10-15 06:38:15 +00:00
|
|
|
controller.SetCmdByte(0, static_cast<int>(scsi_command::eCmdInquiry));
|
2022-11-02 06:36:25 +00:00
|
|
|
EXPECT_EQ(scsi_command::eCmdInquiry, controller.GetOpcode());
|
2022-09-25 21:49:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
TEST(AbstractControllerTest, GetLun)
|
|
|
|
{
|
|
|
|
const int LUN = 3;
|
|
|
|
|
2023-10-15 06:38:15 +00:00
|
|
|
MockAbstractController controller;
|
2022-09-25 21:49:24 +00:00
|
|
|
|
2023-10-15 06:38:15 +00:00
|
|
|
controller.SetCmdByte(1, LUN << 5);
|
2022-09-25 21:49:24 +00:00
|
|
|
EXPECT_EQ(LUN, controller.GetLun());
|
|
|
|
}
|
2022-10-01 15:56:06 +00:00
|
|
|
|
2022-11-02 06:36:25 +00:00
|
|
|
TEST(AbstractControllerTest, Blocks)
|
|
|
|
{
|
2023-10-15 06:38:15 +00:00
|
|
|
MockAbstractController controller;
|
2022-11-02 06:36:25 +00:00
|
|
|
|
|
|
|
controller.SetBlocks(1);
|
2023-10-15 06:38:15 +00:00
|
|
|
EXPECT_TRUE(controller.HasBlocks());
|
2022-11-02 06:36:25 +00:00
|
|
|
controller.DecrementBlocks();
|
2023-10-15 06:38:15 +00:00
|
|
|
EXPECT_FALSE(controller.HasBlocks());
|
2022-11-02 06:36:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
TEST(AbstractControllerTest, Length)
|
2022-10-23 19:51:39 +00:00
|
|
|
{
|
2023-10-15 06:38:15 +00:00
|
|
|
MockAbstractController controller;
|
2022-10-23 19:51:39 +00:00
|
|
|
|
|
|
|
EXPECT_FALSE(controller.HasValidLength());
|
|
|
|
|
|
|
|
controller.SetLength(1);
|
|
|
|
EXPECT_EQ(1, controller.GetLength());
|
|
|
|
EXPECT_TRUE(controller.HasValidLength());
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST(AbstractControllerTest, UpdateOffsetAndLength)
|
2022-10-01 15:56:06 +00:00
|
|
|
{
|
2023-10-15 06:38:15 +00:00
|
|
|
MockAbstractController controller;
|
2022-10-01 15:56:06 +00:00
|
|
|
|
|
|
|
EXPECT_FALSE(controller.HasValidLength());
|
2022-10-04 15:23:42 +00:00
|
|
|
|
|
|
|
controller.UpdateOffsetAndLength();
|
|
|
|
EXPECT_EQ(0, controller.GetLength());
|
2022-10-01 15:56:06 +00:00
|
|
|
}
|
|
|
|
|
2022-10-04 15:23:42 +00:00
|
|
|
TEST(AbstractControllerTest, Offset)
|
|
|
|
{
|
2023-10-15 06:38:15 +00:00
|
|
|
MockAbstractController controller;
|
2022-10-04 15:23:42 +00:00
|
|
|
|
|
|
|
controller.ResetOffset();
|
|
|
|
EXPECT_EQ(0, controller.GetOffset());
|
|
|
|
|
|
|
|
controller.UpdateOffsetAndLength();
|
|
|
|
EXPECT_EQ(0, controller.GetOffset());
|
|
|
|
}
|