RASCSI/cpp/test/rascsi_exceptions_test.cpp
Daniel Markstedt 08194af424
Move C++ code into cpp/ dir (#941)
- Moved C++ code to cpp/ from src/raspberrypi
- Related updates to Makefile, easyinstall.sh, and the github build rules
- Removed the native X68k C code in src/x68k from the repo
2022-10-25 12:59:30 -07:00

54 lines
1.2 KiB
C++

//---------------------------------------------------------------------------
//
// SCSI Target Emulator RaSCSI Reloaded
// for Raspberry Pi
//
// Copyright (C) 2022 Uwe Seimet
//
//---------------------------------------------------------------------------
#include <gtest/gtest.h>
#include "rascsi_exceptions.h"
using namespace scsi_defs;
TEST(RascsiExceptionsTest, IoException)
{
try {
throw io_exception("msg");
}
catch(const io_exception& e) {
EXPECT_STREQ("msg", e.what());
}
}
TEST(RascsiExceptionsTest, FileNotFoundException)
{
try {
throw file_not_found_exception("msg");
}
catch(const file_not_found_exception& e) {
EXPECT_STREQ("msg", e.what());
}
}
TEST(RascsiExceptionsTest, ScsiErrorException)
{
try {
throw scsi_exception(sense_key::UNIT_ATTENTION);
}
catch(const scsi_exception& e) {
EXPECT_EQ(sense_key::UNIT_ATTENTION, e.get_sense_key());
EXPECT_EQ(asc::NO_ADDITIONAL_SENSE_INFORMATION, e.get_asc());
}
try {
throw scsi_exception(sense_key::UNIT_ATTENTION, asc::LBA_OUT_OF_RANGE);
}
catch(const scsi_exception& e) {
EXPECT_EQ(sense_key::UNIT_ATTENTION, e.get_sense_key());
EXPECT_EQ(asc::LBA_OUT_OF_RANGE, e.get_asc());
}
}