Skip to content

Commit

Permalink
refactor(assertion-tools): ♻️ Fix some linting issues
Browse files Browse the repository at this point in the history
  • Loading branch information
DRovara committed Oct 17, 2024
1 parent e4c9046 commit 7f321d8
Show file tree
Hide file tree
Showing 9 changed files with 19 additions and 34 deletions.
16 changes: 7 additions & 9 deletions src/common/parsing/AssertionTools.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,29 +8,27 @@
#include <memory>
#include <string>

bool doesCommuteEnt(const EntanglementAssertion* assertion,
bool doesCommuteEnt(const EntanglementAssertion* assertion, // NOLINT
const std::string& instruction) {
const auto targets = parseParameters(instruction);
return targets.size() < 2; // If the instruction does not target at least two
// qubits, it cannot influence entanglement.
// In theory, even more could be done here, but for now we leave it like this.
}

bool doesCommuteSup(const SuperpositionAssertion* assertion,
bool doesCommuteSup(const SuperpositionAssertion* assertion, // NOLINT
const std::string& instruction) {
const auto targets = parseParameters(instruction);
if (targets.size() >= 2) {
return false; // For controlled gates, it's hard to say how they would
// influence the superposition of the qubits.
}
const auto name = splitString(trim(instruction), ' ')[0];
if (name == "x" || name == "y" || name == "z" || name == "s" || name == "t" ||
name == "sdg" || name == "tdg") {
return true; // Most common Single-qubit gates commute with superposition
// assertions.
}
return false; // For other gates, it's hard to say how they would influence
// the superposition of the qubits.
return (name == "x" || name == "y" || name == "z" || name == "s" ||
name == "t" || name == "sdg" || name == "tdg");
// Most common Single-qubit gates commute with superposition assertions.
// For other gates, it's hard to say how they would influence
// the superposition of the qubits.
}

bool doesCommute(const std::unique_ptr<Assertion>& assertion,
Expand Down
1 change: 0 additions & 1 deletion test/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package_add_test(
mqt_debugger_test
MQT::Debugger
common_fixtures.cpp
utils_test.cpp
test_utility.cpp
test_simulation.cpp
Expand Down
7 changes: 3 additions & 4 deletions test/test_assertion_creation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,16 @@
* @brief Tests the correctness of the assertion creation diagnosis methods.
*/

#include "backend/dd/DDSimDebug.hpp"
#include "backend/debug.h"
#include "backend/diagnostics.h"
#include "common.h"
#include "common_fixtures.cpp"
#include "utils_test.hpp"
#include "common_fixtures.hpp"

#include <algorithm>
#include <array>
#include <cstddef>
#include <gtest/gtest.h>
#include <sstream>
#include <set>
#include <string>
#include <utility>
#include <vector>
Expand Down
10 changes: 2 additions & 8 deletions test/test_assertion_movement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,12 @@
* @brief Tests the correctness of the assertion movement diagnosis methods.
*/

#include "backend/dd/DDSimDebug.hpp"
#include "backend/debug.h"
#include "backend/diagnostics.h"
#include "common.h"
#include "common_fixtures.cpp"
#include "utils_test.hpp"
#include "common_fixtures.hpp"

#include <array>
#include <cstddef>
#include <gtest/gtest.h>
#include <sstream>
#include <string>
#include <set>
#include <utility>
#include <vector>

Expand Down
5 changes: 1 addition & 4 deletions test/test_custom_code.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,15 @@
* are not covered by the other tests.
*/

#include "backend/dd/DDSimDebug.hpp"
#include "backend/debug.h"
#include "backend/diagnostics.h"
#include "common.h"
#include "common_fixtures.cpp"
#include "common_fixtures.hpp"
#include "utils_test.hpp"

#include <array>
#include <cstddef>
#include <gtest/gtest.h>
#include <sstream>
#include <string>

/**
* @brief Fixture for testing the correctness of the debugger on custom code.
Expand Down
3 changes: 1 addition & 2 deletions test/test_data_retrieval.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,9 @@
* vector.
*/

#include "backend/dd/DDSimDebug.hpp"
#include "backend/debug.h"
#include "common.h"
#include "common_fixtures.cpp"
#include "common_fixtures.hpp"
#include "utils_test.hpp"

#include <array>
Expand Down
4 changes: 1 addition & 3 deletions test/test_diagnostics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,10 @@
* @brief Test the functionality of the diagnostics module.
*/

#include "backend/dd/DDSimDebug.hpp"
#include "backend/debug.h"
#include "backend/diagnostics.h"
#include "common.h"
#include "common_fixtures.cpp"
#include "utils_test.hpp"
#include "common_fixtures.hpp"

#include <array>
#include <cstddef>
Expand Down
4 changes: 1 addition & 3 deletions test/test_utility.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@
* @file test_utility.cpp
* @brief Test the functionality of utility functions provided by the debugger.
*/
#include "backend/dd/DDSimDebug.hpp"
#include "backend/debug.h"
#include "common.h"
#include "common_fixtures.cpp"
#include "utils_test.hpp"
#include "common_fixtures.hpp"

#include <cstddef>
#include <gtest/gtest.h>
Expand Down
3 changes: 3 additions & 0 deletions test/common_fixtures.cpp → test/utils/common_fixtures.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,13 @@
#include "backend/dd/DDSimDiagnostics.hpp"
#include "backend/debug.h"
#include "backend/diagnostics.h"
#include "common.h"
#include "utils_test.hpp"

#include <cstddef>
#include <gtest/gtest.h>
#include <sstream>
#include <string>

/**
* @brief Fixture that loads custom code.
Expand Down

0 comments on commit 7f321d8

Please sign in to comment.