Skip to content

Commit

Permalink
Re-add unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
uweseimet committed Oct 20, 2024
1 parent 37b5d1b commit 768757f
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
18 changes: 18 additions & 0 deletions cpp/test/disk_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -462,6 +462,24 @@ TEST(DiskTest, ModeSense10)
ValidateCachingPage(*controller, 16);
}

TEST(DiskTest, ReadData)
{
MockDisk disk;

EXPECT_THAT([&] {disk.ReadData( {});}, Throws<scsi_exception>(AllOf(
Property(&scsi_exception::get_sense_key, sense_key::not_ready),
Property(&scsi_exception::get_asc, asc::medium_not_present)))) << "Disk is not ready";
}

TEST(DiskTest, WriteData)
{
MockDisk disk;

EXPECT_THAT([&] {disk.WriteData( {}, scsi_command::write6);}, Throws<scsi_exception>(AllOf(
Property(&scsi_exception::get_sense_key, sense_key::not_ready),
Property(&scsi_exception::get_asc, asc::medium_not_present)))) << "Disk is not ready";
}

TEST(DiskTest, SynchronizeCache)
{
auto [controller, disk] = CreateDisk();
Expand Down
7 changes: 7 additions & 0 deletions cpp/test/scsi_cd_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,3 +119,10 @@ TEST(ScsiCdTest, ReadToc)
EXPECT_CALL(controller, DataIn());
EXPECT_NO_THROW(cd->Dispatch(scsi_command::read_toc));
}

TEST(ScsiCdTest, ReadData)
{
ScsiCd cd(0);

EXPECT_THROW(cd.ReadData( {}), scsi_exception)<< "Drive is not ready";
}

0 comments on commit 768757f

Please sign in to comment.