Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions unittests/nvqpp/integration/draw_tester.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,3 +132,25 @@ CUDAQ_TEST(LatexDrawTester, skipsNonGateInstructions) {

EXPECT_EQ(expected_str, cudaq::detail::getLaTeXString(trace));
}

CUDAQ_TEST(DrawTester, skipsNonGateInstructions) {
// Regression test: a measurement in the middle of the trace must not
// misalign the instruction indices used by the layers and the boxes.
cudaq::Trace trace;
trace.appendInstruction("h", {}, {}, {{2, 2}});
trace.appendMeasurement("mz", {{2, 2}});
trace.appendInstruction("x", {}, {}, {{2, 2}});

// clang-format off
const std::string expected_str = R"(
q0 : ──────────

q1 : ──────────
╭───╮╭───╮
q2 : ┤ h ├┤ x ├
╰───╯╰───╯
)";
// clang-format on

EXPECT_EQ(expected_str, cudaq::detail::draw(trace));
}