test/devices/block/ramdisk/ramdisk_tests.cpp
// Check that it is not possible to do any operations on an empty Ramdisk
Check that it is not possible to do any operations on an empty Ramdisk
Check that it is not possible to do any operations on an empty Ramdisk
TEST(RamdiskTest, EmptyDevice)
{
  std::unique_ptr<ramdisk_device> device(std::make_unique<ramdisk_device>(0, 0));
  std::unique_ptr<char []> buffer(new char[10]);
  ASSERT_EQ(device->num_blocks(), 0);
  ASSERT_EQ(device->block_size(), 0);
  device->start();
  ASSERT_EQ(device->get_device_status(), DEV_STATUS::FAILED);
  ASSERT_EQ(device->read_blocks(0, 5, buffer.get(), 10), ERR_CODE::DEVICE_FAILED);
  ASSERT_EQ(device->write_blocks(0, 5, buffer.get(), 10), ERR_CODE::DEVICE_FAILED);
  test_only_reset_name_counts();
}
TEST ( RamdiskTest , EmptyDevice ) { std :: unique_ptr < ramdisk_device > device ( std :: make_unique < ramdisk_device > ( 0 , 0 ) ) ; std :: unique_ptr < char [ ] > buffer ( new char [ 10 ] ) ; ASSERT_EQ ( device -> num_blocks ( ) , 0 ) ; ASSERT_EQ ( device -> block_size ( ) , 0 ) ; device -> start ( ) ; ASSERT_EQ ( device -> get_device_status ( ) , DEV_STATUS :: FAILED ) ; ASSERT_EQ ( device -> read_blocks ( 0 , 5 , buffer . get ( ) , 10 ) , ERR_CODE :: DEVICE_FAILED ) ; ASSERT_EQ ( device -> write_blocks ( 0 , 5 , buffer . get ( ) , 10 ) , ERR_CODE :: DEVICE_FAILED ) ; test_only_reset_name_counts ( ) ; }
Check that it is not possible to do any operations on an empty Ramdisk
Check that it is not possible to do any operations on an empty Ramdisk