RASCSI/cpp/test/gpiobus_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

49 lines
1.3 KiB
C++

//---------------------------------------------------------------------------
//
// SCSI Target Emulator RaSCSI Reloaded
// for Raspberry Pi
//
// Copyright (C) 2022 Uwe Seimet
//
//---------------------------------------------------------------------------
#include <gtest/gtest.h>
#include "hal/gpiobus.h"
#include <unordered_set>
TEST(GpioBusTest, GetCommandByteCount)
{
unordered_set<int> opcodes;
EXPECT_EQ(16, GPIOBUS::GetCommandByteCount(0x88));
opcodes.insert(0x88);
EXPECT_EQ(16, GPIOBUS::GetCommandByteCount(0x8a));
opcodes.insert(0x8a);
EXPECT_EQ(16, GPIOBUS::GetCommandByteCount(0x8f));
opcodes.insert(0x8f);
EXPECT_EQ(16, GPIOBUS::GetCommandByteCount(0x91));
opcodes.insert(0x91);
EXPECT_EQ(16, GPIOBUS::GetCommandByteCount(0x9e));
opcodes.insert(0x9e);
EXPECT_EQ(16, GPIOBUS::GetCommandByteCount(0x9f));
opcodes.insert(0x9f);
EXPECT_EQ(12, GPIOBUS::GetCommandByteCount(0xa0));
opcodes.insert(0xa0);
// TODO Opcode 0x05 must be removed from gpiobus.cpp
EXPECT_EQ(10, GPIOBUS::GetCommandByteCount(0x05));
opcodes.insert(0x05);
for (int i = 0x20; i <= 0x7d; i++) {
EXPECT_EQ(10, GPIOBUS::GetCommandByteCount(i));
opcodes.insert(i);
}
for (int i = 0; i < 256; i++) {
if (opcodes.find(i) == opcodes.end()) {
EXPECT_EQ(6, GPIOBUS::GetCommandByteCount(i));
}
}
}