Skip to content

Commit

Permalink
✅ add tests for new feature
Browse files Browse the repository at this point in the history
Signed-off-by: Lukas Burgholzer <[email protected]>
  • Loading branch information
burgholzer committed May 5, 2022
1 parent d46a2ac commit f08c748
Showing 1 changed file with 48 additions and 0 deletions.
48 changes: 48 additions & 0 deletions test/test_exact.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -406,3 +406,51 @@ TEST_F(ExactTest, WCNF) {
std::cout << wcnf << std::endl;
EXPECT_TRUE(!wcnf.empty());
}

TEST_F(ExactTest, MapToSubgraph) {
using namespace dd::literals;

qc.addQubitRegister(3U);
qc.x(0, 1_pc);
qc.x(1, 2_pc);
qc.x(2, 0_pc);

const auto connectedSubset = std::set<unsigned short>{0U, 1U, 2U};

settings.subgraph = connectedSubset;
IBMQ_London_mapper.map(settings);
const auto& results = IBMQ_London_mapper.getResults();
EXPECT_FALSE(results.timeout);
}

TEST_F(ExactTest, MapToSubgraphTooSmall) {
using namespace dd::literals;

qc.addQubitRegister(3U);
qc.x(0, 1_pc);
qc.x(1, 2_pc);
qc.x(2, 0_pc);

const auto tooSmallSubset = std::set<unsigned short>{0U, 1U};

settings.subgraph = tooSmallSubset;
IBMQ_London_mapper.map(settings);
const auto& results = IBMQ_London_mapper.getResults();
EXPECT_TRUE(results.timeout);
}

TEST_F(ExactTest, MapToSubgraphNotConnected) {
using namespace dd::literals;

qc.addQubitRegister(3U);
qc.x(0, 1_pc);
qc.x(1, 2_pc);
qc.x(2, 0_pc);

const auto nonConnectedSubset = std::set<unsigned short>{0U, 2U, 3U};

settings.subgraph = nonConnectedSubset;
IBMQ_London_mapper.map(settings);
const auto& results = IBMQ_London_mapper.getResults();
EXPECT_TRUE(results.timeout);
}

0 comments on commit f08c748

Please sign in to comment.