1#include <gmock/gmock.h>
2#include <gtest/gtest.h>
11size_t compute_instruction_size(
WireOpCode wire_opcode,
15 size_t instr_size = 1;
16 for (
const auto& operand_type : wire_format.at(wire_opcode)) {
17 instr_size += operand_type_sizes.at(operand_type);
25TEST(InstructionSpecTest, CheckAllInstructionSizes)
31 const auto wire_opcode =
static_cast<WireOpCode>(i);
32 const auto computed_size = compute_instruction_size(wire_opcode, wire_format, operand_type_sizes);
34 <<
"Incorrect size_in_bytes field for " << wire_opcode <<
" in WIRE_INSTRUCTION_SPEC.";
40TEST(InstructionSpecTest, CheckAllInstructionsTagInformation)
45 const auto wire_opcode =
static_cast<WireOpCode>(i);
46 const auto& operands = wire_format.at(wire_opcode);
50 if (wire_instruction_spec.tag_operand_idx.has_value()) {
51 EXPECT_EQ(tag_counts, 1);
52 if (wire_instruction_spec.tag_operand_idx.value() == 2) {
58 EXPECT_EQ(tag_counts, 0);
66TEST(InstructionSpecTest, CheckWireOpCodeAndExecOpcodeConsistency)
70 const auto wire_opcode =
static_cast<WireOpCode>(i);
74 exec_opcodes.insert(wire_instruction_spec.exec_opcode);
79 EXPECT_TRUE(exec_opcodes.contains(exec_opcode));
84TEST(InstructionSpecTest, CheckDecomposeWindowSize)
87 static const uint32_t MAX_INSTRUCTION_SIZE =
88 std::ranges::max_element(
91 [](
const auto&
a,
const auto&
b) { return a.second.size_in_bytes < b.second.size_in_bytes; })
92 ->second.size_in_bytes;
const std::unordered_map< OperandType, uint32_t > & get_operand_type_sizes()
const std::unordered_map< WireOpCode, std::vector< OperandType > > & get_instruction_wire_formats()
TEST(EmitUnencryptedLogTest, Basic)
constexpr uint32_t DECOMPOSE_WINDOW_SIZE
const std::unordered_map< WireOpCode, WireInstructionSpec > WIRE_INSTRUCTION_SPEC
const std::unordered_map< ExecutionOpCode, ExecInstructionSpec > EXEC_INSTRUCTION_SPEC
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept