Skip to content

Commit

Permalink
Add test for node type
Browse files Browse the repository at this point in the history
  • Loading branch information
ZehMatt committed Sep 5, 2024
1 parent 2d1a21c commit 74d5cbb
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions tests/src/tests/tests.program.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -347,4 +347,26 @@ namespace zasm::tests
ASSERT_EQ(imm.value<int>(), 3);
}

TEST(ProgramTests, TestNodeType)
{
Program program(MachineMode::AMD64);

auto testIns = Instruction{}.setMnemonic(x86::Mnemonic::Add);

auto* node = program.createNode(testIns);
ASSERT_NE(node, nullptr);

ASSERT_TRUE(node->holds<Instruction>());

ASSERT_FALSE(node->holds<Data>());

auto* inst = node->getIf<Instruction>();
ASSERT_NE(inst, nullptr);

ASSERT_EQ(testIns, *inst);

auto* data = node->getIf<Data>();
ASSERT_EQ(data, nullptr);
}

} // namespace zasm::tests

0 comments on commit 74d5cbb

Please sign in to comment.