2022-10-06 14:15:19 +00:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// SCSI Target Emulator RaSCSI Reloaded
|
|
|
|
// for Raspberry Pi
|
|
|
|
//
|
|
|
|
// Copyright (C) 2022 Uwe Seimet
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2022-10-23 19:51:39 +00:00
|
|
|
#include <gtest/gtest.h>
|
2022-10-08 17:26:04 +00:00
|
|
|
|
2022-10-06 14:15:19 +00:00
|
|
|
#include "rascsi/command_context.h"
|
|
|
|
|
2022-10-08 17:26:04 +00:00
|
|
|
TEST(CommandContext, GetSerializer)
|
|
|
|
{
|
|
|
|
CommandContext context("", -1);
|
|
|
|
|
|
|
|
// There is nothing more that can be tested
|
|
|
|
context.GetSerializer();
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST(CommandContext, IsValid)
|
|
|
|
{
|
|
|
|
CommandContext context("", -1);
|
|
|
|
|
|
|
|
EXPECT_FALSE(context.IsValid());
|
|
|
|
|
|
|
|
context.SetFd(1);
|
|
|
|
EXPECT_TRUE(context.IsValid());
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST(CommandContext, Cleanup)
|
|
|
|
{
|
|
|
|
CommandContext context("", 0);
|
|
|
|
|
|
|
|
EXPECT_EQ(0, context.GetFd());
|
|
|
|
context.Cleanup();
|
|
|
|
EXPECT_EQ(-1, context.GetFd());
|
|
|
|
}
|
2022-10-06 14:15:19 +00:00
|
|
|
|
|
|
|
TEST(CommandContext, ReturnLocalizedError)
|
|
|
|
{
|
2022-10-08 17:26:04 +00:00
|
|
|
CommandContext context("en_US", -1);
|
2022-10-06 14:15:19 +00:00
|
|
|
|
|
|
|
EXPECT_FALSE(context.ReturnLocalizedError(LocalizationKey::ERROR_LOG_LEVEL));
|
|
|
|
}
|
2022-10-08 17:26:04 +00:00
|
|
|
|
|
|
|
TEST(CommandContext, ReturnStatus)
|
|
|
|
{
|
|
|
|
CommandContext context("", -1);
|
|
|
|
|
|
|
|
EXPECT_TRUE(context.ReturnStatus(true, "status"));
|
|
|
|
EXPECT_FALSE(context.ReturnStatus(false, "status"));
|
|
|
|
}
|