diff --git a/.github/CHANGELOG.md b/.github/CHANGELOG.md
index 6a03c14fa5..cbaf15d250 100644
--- a/.github/CHANGELOG.md
+++ b/.github/CHANGELOG.md
@@ -35,6 +35,9 @@
Internal changes ⚙️
+- Update Catch2 testing framework to v3.11.
+ [(#1350)](https://github.com/PennyLaneAI/pennylane-lightning/pull/1350)
+
- Update internal dependencies versions for Nanobind (2.11), cmake (3.26), sphinxcontrib-htmlhelp (2.1.0)
[(#1347)](https://github.com/PennyLaneAI/pennylane-lightning/pull/1347)
diff --git a/.github/workflows/tests_lgpumpi_cpp.yml b/.github/workflows/tests_lgpumpi_cpp.yml
index dab42477bf..ea16fa04b2 100644
--- a/.github/workflows/tests_lgpumpi_cpp.yml
+++ b/.github/workflows/tests_lgpumpi_cpp.yml
@@ -167,7 +167,7 @@ jobs:
mkdir -p ./tests/results
test_status=0
for file in *runner ; do ./$file --reporter junit --out ./tests/results/report_$file.xml && echo "Test $file Success!" || { cat ./tests/results/report_$file.xml; test_status=1; } done;
- for file in *runner_mpi ; do mpirun -np 2 ./$file --reporter junit --out ./tests/results/report_$file.xml && echo "Test $file Success!" || { cat ./tests/results/report_$file.xml; test_status=1; } done;
+ for file in *runner_mpi ; do mpirun -np 2 ./$file --order decl --reporter junit --out ./tests/results/report_$file.xml && echo "Test $file Success!" || { cat ./tests/results/report_$file.xml; test_status=1; } done;
if [ $test_status -ne 0 ]; then
echo "Tests failed. Exiting with error code."
exit 1
diff --git a/.github/workflows/tests_lkmpi_cuda_cpp.yml b/.github/workflows/tests_lkmpi_cuda_cpp.yml
index f7f6be67b7..c8782b4e6a 100644
--- a/.github/workflows/tests_lkmpi_cuda_cpp.yml
+++ b/.github/workflows/tests_lkmpi_cuda_cpp.yml
@@ -193,8 +193,8 @@ jobs:
mkdir -p ./tests/results
test_status=0
for file in *runner ; do ./$file --reporter junit --out ./tests/results/report_$file.xml && echo "Test $file Success!" || { cat ./tests/results/report_$file.xml; test_status=1; } done;
- for file in lightning_kokkos*runner_mpi ; do mpirun -np 4 ./$file --reporter junit --out ./tests/results/report_$file.xml && echo "Test $file Success!" || { cat ./tests/results/report_$file.xml; test_status=1; } done;
- for file in utils_*runner_mpi ; do mpirun -np 2 ./$file --reporter junit --out ./tests/results/report_$file.xml && echo "Test $file Success!" || { cat ./tests/results/report_$file.xml; test_status=1; } done;
+ for file in lightning_kokkos*runner_mpi ; do mpirun -np 4 ./$file --order decl --reporter junit --out ./tests/results/report_$file.xml && echo "Test $file Success!" || { cat ./tests/results/report_$file.xml; test_status=1; } done;
+ for file in utils_*runner_mpi ; do mpirun -np 2 ./$file --order decl --reporter junit --out ./tests/results/report_$file.xml && echo "Test $file Success!" || { cat ./tests/results/report_$file.xml; test_status=1; } done;
if [ $test_status -ne 0 ]; then
echo "Tests failed. Exiting with error code."
exit 1
diff --git a/Makefile b/Makefile
index c0cd20b034..39733050d6 100644
--- a/Makefile
+++ b/Makefile
@@ -156,23 +156,23 @@ test-cpp-mpi:
$(OPTIONS)
ifdef target
cmake --build ./BuildTests $(VERBOSE) --target $(target)
- mpirun -np 2 ./BuildTests/$(target)
+ mpirun -np 2 ./BuildTests/$(target) --order decl
else
cmake --build ./BuildTests $(VERBOSE)
-
+
if [ "$(PL_BACKEND)" = "lightning_gpu" ]; then \
for file in ./BuildTests/*_test_runner_mpi; do \
echo "Running $$file"; \
- mpirun -np 2 $$file ; \
+ mpirun -np 2 $$file --order decl ; \
done ; \
elif [ "$(PL_BACKEND)" = "lightning_kokkos" ]; then \
for file in ./BuildTests/lightning_kokkos*test_runner_mpi; do \
echo "Running $$file"; \
- mpirun -np 4 $$file ; \
+ mpirun -np 4 $$file --order decl ; \
done ; \
for file in ./BuildTests/utils_test_runner_mpi; do \
echo "Running $$file"; \
- mpirun -np 2 $$file ; \
+ mpirun -np 2 $$file --order decl ; \
done; \
fi
endif
diff --git a/cmake/support_tests.cmake b/cmake/support_tests.cmake
index 827d050c9d..793df71f54 100644
--- a/cmake/support_tests.cmake
+++ b/cmake/support_tests.cmake
@@ -13,7 +13,7 @@ macro(FetchAndIncludeCatch)
FetchContent_Declare(
Catch2
GIT_REPOSITORY https://github.com/catchorg/Catch2.git
- GIT_TAG v2.13.10
+ GIT_TAG v3.11.0
)
FetchContent_MakeAvailable(Catch2)
@@ -22,7 +22,7 @@ macro(FetchAndIncludeCatch)
set_target_properties(Catch2 PROPERTIES INTERFACE_SYSTEM_INCLUDE_DIRECTORIES "${CATCH2_IID}")
# Required for catch_discover_tests() and include(Catch)
- list(APPEND CMAKE_MODULE_PATH ${catch2_SOURCE_DIR}/contrib)
+ list(APPEND CMAKE_MODULE_PATH ${catch2_SOURCE_DIR}/extras)
include(Catch)
endmacro()
@@ -48,4 +48,4 @@ macro(ProcessTestOptions target_name)
message(STATUS "ENABLE_NATIVE is ON. Use -march=native for cpptests.")
target_compile_options(${target_name} INTERFACE -march=native)
endif()
-endmacro()
\ No newline at end of file
+endmacro()
diff --git a/pennylane_lightning/core/_version.py b/pennylane_lightning/core/_version.py
index fa40379eb5..2e003b71ba 100644
--- a/pennylane_lightning/core/_version.py
+++ b/pennylane_lightning/core/_version.py
@@ -16,4 +16,4 @@
Version number (major.minor.patch[-label])
"""
-__version__ = "0.45.0-dev25"
+__version__ = "0.45.0-dev26"
diff --git a/pennylane_lightning/core/algorithms/tests/Test_AdjointJacobian.cpp b/pennylane_lightning/core/algorithms/tests/Test_AdjointJacobian.cpp
index a18221c145..6d01341d73 100644
--- a/pennylane_lightning/core/algorithms/tests/Test_AdjointJacobian.cpp
+++ b/pennylane_lightning/core/algorithms/tests/Test_AdjointJacobian.cpp
@@ -11,7 +11,8 @@
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
-#include
+#include
+#include
#include "Error.hpp" // LightningException
#include "JacobianData.hpp"
diff --git a/pennylane_lightning/core/algorithms/tests/mpi/Test_AdjointJacobianMPI.cpp b/pennylane_lightning/core/algorithms/tests/mpi/Test_AdjointJacobianMPI.cpp
index 6b8cf7e44a..650eb73ded 100644
--- a/pennylane_lightning/core/algorithms/tests/mpi/Test_AdjointJacobianMPI.cpp
+++ b/pennylane_lightning/core/algorithms/tests/mpi/Test_AdjointJacobianMPI.cpp
@@ -11,7 +11,7 @@
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
-#include
+#include
#include "JacobianData.hpp"
#include "TestHelpers.hpp" //PLApprox
diff --git a/pennylane_lightning/core/algorithms/tests/mpi/runner_algorithms_mpi.cpp b/pennylane_lightning/core/algorithms/tests/mpi/runner_algorithms_mpi.cpp
index 3bed64f9d3..1dfe3b5032 100644
--- a/pennylane_lightning/core/algorithms/tests/mpi/runner_algorithms_mpi.cpp
+++ b/pennylane_lightning/core/algorithms/tests/mpi/runner_algorithms_mpi.cpp
@@ -1,5 +1,5 @@
#define CATCH_CONFIG_RUNNER
-#include
+#include
#include
int main(int argc, char *argv[]) {
diff --git a/pennylane_lightning/core/algorithms/tests/runner_algorithms.cpp b/pennylane_lightning/core/algorithms/tests/runner_algorithms.cpp
index 4ed06df1f7..64ba13906f 100644
--- a/pennylane_lightning/core/algorithms/tests/runner_algorithms.cpp
+++ b/pennylane_lightning/core/algorithms/tests/runner_algorithms.cpp
@@ -1,2 +1,3 @@
-#define CATCH_CONFIG_MAIN
-#include
+#include
+
+int main(int argc, char *argv[]) { return Catch::Session().run(argc, argv); }
diff --git a/pennylane_lightning/core/bindings/BindingsMPI.hpp b/pennylane_lightning/core/bindings/BindingsMPI.hpp
index d0332a80d5..a7023fc205 100644
--- a/pennylane_lightning/core/bindings/BindingsMPI.hpp
+++ b/pennylane_lightning/core/bindings/BindingsMPI.hpp
@@ -427,7 +427,7 @@ void registerBackendAgnosticAlgorithmsMPI(nb::module_ &m) {
*
* @param m Nanobind module
*/
-inline void registerInfoMPI(nb::module_ &m) {
+inline void registerInfoMPI([[maybe_unused]] nb::module_ &m) {
// This function is now empty - MPI manager registration moved to
// backend-specific
}
diff --git a/pennylane_lightning/core/catalyst/tests/Test_LightningDriver.cpp b/pennylane_lightning/core/catalyst/tests/Test_LightningDriver.cpp
index d355dbf875..8389fbe380 100644
--- a/pennylane_lightning/core/catalyst/tests/Test_LightningDriver.cpp
+++ b/pennylane_lightning/core/catalyst/tests/Test_LightningDriver.cpp
@@ -13,8 +13,9 @@
// limitations under the License.
#include "TestHelpers.hpp"
-#include "catch2/catch.hpp"
#include
+#include
+#include
#include
#include
@@ -162,7 +163,7 @@ TEST_CASE("Check an unsupported operation", "[Driver]") {
REQUIRE_THROWS_WITH(
Lightning::lookup_gates(Lightning::simulator_gate_info,
"UnsupportedGateName"),
- Catch::Contains(
+ Catch::Matchers::ContainsSubstring(
"The given operation is not supported by the simulator"));
}
@@ -447,8 +448,9 @@ TEST_CASE("Cannot reuse entangled qubit when allocating", "[Driver]") {
REQUIRE_THROWS_WITH(
sim->AllocateQubit(),
- Catch::Contains("Cannot reuse qubit: qubit is entangled with remaining "
- "qubits. Release qubits must be disentangled."));
+ Catch::Matchers::ContainsSubstring(
+ "Cannot reuse qubit: qubit is entangled with remaining "
+ "qubits. Release qubits must be disentangled."));
}
TEST_CASE("Release one qubit from entangled qubits", "[Driver]") {
@@ -478,8 +480,9 @@ TEST_CASE("Release one qubit from entangled qubits", "[Driver]") {
REQUIRE_THROWS_WITH(
sim->PartialProbs(probs_view, {static_qubits[0], static_qubits[1]}),
- Catch::Contains("Cannot release qubits: released qubits are entangled "
- "with remaining qubits"));
+ Catch::Matchers::ContainsSubstring(
+ "Cannot release qubits: released qubits are entangled "
+ "with remaining qubits"));
}
TEST_CASE("Release all entangled qubits", "[Driver]") {
diff --git a/pennylane_lightning/core/catalyst/tests/Test_LightningQubitManager.cpp b/pennylane_lightning/core/catalyst/tests/Test_LightningQubitManager.cpp
index 04c2134811..ff8516adcb 100644
--- a/pennylane_lightning/core/catalyst/tests/Test_LightningQubitManager.cpp
+++ b/pennylane_lightning/core/catalyst/tests/Test_LightningQubitManager.cpp
@@ -16,7 +16,8 @@
#include
#include
-#include "catch2/catch.hpp"
+#include
+#include
#include "LightningQubitManager.hpp"
@@ -98,12 +99,14 @@ TEST_CASE("Test lightning qubit manager invalid IDs", "[Utils]") {
size_t device_qubit_id = 0;
QubitIdType q = manager.Allocate(device_qubit_id);
- REQUIRE_THROWS_WITH(manager.getProgramId(device_qubit_id + 42),
- Catch::Contains("Invalid device qubit ID"));
- REQUIRE_THROWS_WITH(manager.getDeviceId(q + 42),
- Catch::Contains("Invalid program qubit ID"));
-
REQUIRE_THROWS_WITH(
- manager.Release(q + 42),
- Catch::Contains("Cannot release qubit, the given ID is invalid"));
+ manager.getProgramId(device_qubit_id + 42),
+ Catch::Matchers::ContainsSubstring("Invalid device qubit ID"));
+ REQUIRE_THROWS_WITH(
+ manager.getDeviceId(q + 42),
+ Catch::Matchers::ContainsSubstring("Invalid program qubit ID"));
+
+ REQUIRE_THROWS_WITH(manager.Release(q + 42),
+ Catch::Matchers::ContainsSubstring(
+ "Cannot release qubit, the given ID is invalid"));
}
diff --git a/pennylane_lightning/core/catalyst/tests/runner_catalyst.cpp b/pennylane_lightning/core/catalyst/tests/runner_catalyst.cpp
index 4ed06df1f7..64ba13906f 100644
--- a/pennylane_lightning/core/catalyst/tests/runner_catalyst.cpp
+++ b/pennylane_lightning/core/catalyst/tests/runner_catalyst.cpp
@@ -1,2 +1,3 @@
-#define CATCH_CONFIG_MAIN
-#include
+#include
+
+int main(int argc, char *argv[]) { return Catch::Session().run(argc, argv); }
diff --git a/pennylane_lightning/core/measurements/tests/Test_MeasurementsBase.cpp b/pennylane_lightning/core/measurements/tests/Test_MeasurementsBase.cpp
index e8ff3bdff4..efba57ff7e 100644
--- a/pennylane_lightning/core/measurements/tests/Test_MeasurementsBase.cpp
+++ b/pennylane_lightning/core/measurements/tests/Test_MeasurementsBase.cpp
@@ -12,7 +12,10 @@
// See the License for the specific language governing permissions and
// limitations under the License.
#include "TestHelpers.hpp"
-#include
+#include
+#include
+#include
+#include
/// @cond DEV
namespace {
@@ -129,8 +132,9 @@ template void testProbabilities() {
<< StateVectorToName::name) {
for (const auto &term : input) {
probabilities = Measurer.probs(term.first);
- REQUIRE_THAT(term.second,
- Catch::Approx(probabilities).margin(1e-6));
+ REQUIRE_THAT(
+ term.second,
+ Catch::Matchers::Approx(probabilities).margin(1e-6));
}
}
@@ -179,7 +183,7 @@ template void testProbabilitiesShots() {
std::size_t num_shots = 10000;
probabilities = Measurer.probs(num_shots);
REQUIRE_THAT(input[0].second,
- Catch::Approx(probabilities).margin(5e-2));
+ Catch::Matchers::Approx(probabilities).margin(5e-2));
}
DYNAMIC_SECTION(
@@ -188,8 +192,9 @@ template void testProbabilitiesShots() {
for (const auto &term : input) {
std::size_t num_shots = 10000;
probabilities = Measurer.probs(term.first, num_shots);
- REQUIRE_THAT(term.second,
- Catch::Approx(probabilities).margin(5e-2));
+ REQUIRE_THAT(
+ term.second,
+ Catch::Matchers::Approx(probabilities).margin(5e-2));
}
}
@@ -232,7 +237,8 @@ template void testProbabilitiesObs() {
auto prob_obs = Measurer_obs.probs(obs);
auto prob = Measurer.probs(std::vector({i}));
- REQUIRE_THAT(prob_obs, Catch::Approx(prob).margin(1e-6));
+ REQUIRE_THAT(prob_obs,
+ Catch::Matchers::Approx(prob).margin(1e-6));
}
}
@@ -250,7 +256,8 @@ template void testProbabilitiesObs() {
auto prob_obs = Measurer_obs.probs(obs);
auto prob = Measurer.probs(std::vector({i}));
- REQUIRE_THAT(prob_obs, Catch::Approx(prob).margin(1e-6));
+ REQUIRE_THAT(prob_obs,
+ Catch::Matchers::Approx(prob).margin(1e-6));
}
}
@@ -265,7 +272,8 @@ template void testProbabilitiesObs() {
auto prob_obs = Measurer_obs.probs(obs);
auto prob = Measurer.probs(std::vector({i}));
- REQUIRE_THAT(prob_obs, Catch::Approx(prob).margin(1e-6));
+ REQUIRE_THAT(prob_obs,
+ Catch::Matchers::Approx(prob).margin(1e-6));
}
}
@@ -282,7 +290,8 @@ template void testProbabilitiesObs() {
auto prob_obs = Measurer_obs.probs(obs);
auto prob = Measurer.probs(std::vector({i}));
- REQUIRE_THAT(prob_obs, Catch::Approx(prob).margin(1e-6));
+ REQUIRE_THAT(prob_obs,
+ Catch::Matchers::Approx(prob).margin(1e-6));
}
}
@@ -297,7 +306,8 @@ template void testProbabilitiesObs() {
auto prob_obs = Measurer_obs.probs(obs);
auto prob = Measurer.probs(std::vector({i}));
- REQUIRE_THAT(prob_obs, Catch::Approx(prob).margin(1e-6));
+ REQUIRE_THAT(prob_obs,
+ Catch::Matchers::Approx(prob).margin(1e-6));
}
}
@@ -322,7 +332,7 @@ template void testProbabilitiesObs() {
auto prob_obs = Measurer_obs.probs(*obs);
auto prob = Measurer.probs(std::vector({0, 1, 2}));
- REQUIRE_THAT(prob_obs, Catch::Approx(prob).margin(1e-6));
+ REQUIRE_THAT(prob_obs, Catch::Matchers::Approx(prob).margin(1e-6));
}
DYNAMIC_SECTION("Test TensorProd YHI"
@@ -347,7 +357,7 @@ template void testProbabilitiesObs() {
auto prob_obs = Measurer_obs.probs(*obs);
auto prob = Measurer.probs(std::vector({0, 1, 2}));
- REQUIRE_THAT(prob_obs, Catch::Approx(prob).margin(1e-6));
+ REQUIRE_THAT(prob_obs, Catch::Matchers::Approx(prob).margin(1e-6));
}
testProbabilitiesObs();
@@ -396,7 +406,8 @@ template void testProbabilitiesObsShots() {
auto prob = Measurer.probs(std::vector({0, 1, 2}));
- REQUIRE_THAT(prob_obs_shots, Catch::Approx(prob).margin(5e-2));
+ REQUIRE_THAT(prob_obs_shots,
+ Catch::Matchers::Approx(prob).margin(5e-2));
}
DYNAMIC_SECTION("Test TensorProd YHI"
@@ -422,7 +433,8 @@ template void testProbabilitiesObsShots() {
auto prob_obs_shots = Measurer_obs_shots.probs(*obs, num_shots);
auto prob = Measurer.probs(std::vector({0, 1, 2}));
- REQUIRE_THAT(prob_obs_shots, Catch::Approx(prob).margin(5e-2));
+ REQUIRE_THAT(prob_obs_shots,
+ Catch::Matchers::Approx(prob).margin(5e-2));
}
testProbabilitiesObsShots();
@@ -1290,8 +1302,9 @@ void testSamples(const std::optional &seed = std::nullopt) {
DYNAMIC_SECTION("No wires provided - "
<< StateVectorToName::name) {
- REQUIRE_THAT(probabilities,
- Catch::Approx(expected_probabilities).margin(.05));
+ REQUIRE_THAT(
+ probabilities,
+ Catch::Matchers::Approx(expected_probabilities).margin(.05));
}
testSamples(seed);
}
@@ -1419,8 +1432,9 @@ template void testSamplesCountsObs() {
probabilities[i] = counts[i] / (PrecisionT)num_samples;
}
- REQUIRE_THAT(probabilities,
- Catch::Approx(expected_probabilities).margin(.05));
+ REQUIRE_THAT(
+ probabilities,
+ Catch::Matchers::Approx(expected_probabilities).margin(.05));
}
DYNAMIC_SECTION("counts() without obs"
@@ -1453,8 +1467,9 @@ template void testSamplesCountsObs() {
probabilities[i] = counts[i] / (PrecisionT)num_samples;
}
- REQUIRE_THAT(probabilities,
- Catch::Approx(expected_probabilities).margin(.05));
+ REQUIRE_THAT(
+ probabilities,
+ Catch::Matchers::Approx(expected_probabilities).margin(.05));
}
testSamplesCountsObs();
@@ -1700,18 +1715,19 @@ template void testSparseHObsMeasureShot() {
std::vector shots_range = {};
REQUIRE_THROWS_WITH(
Measurer.expval(*sparseH, num_shots, shots_range),
- Catch::Matchers::Contains("SparseHamiltonian observables do "
- "not support shot measurement."));
+ Catch::Matchers::ContainsSubstring(
+ "SparseHamiltonian observables do "
+ "not support shot measurement."));
}
DYNAMIC_SECTION("Failed for var "
<< StateVectorToName::name) {
std::size_t num_shots = 1000;
std::vector shots_range = {};
- REQUIRE_THROWS_WITH(
- Measurer.var(*sparseH, num_shots),
- Catch::Matchers::Contains("SparseHamiltonian observables do "
- "not support shot measurement."));
+ REQUIRE_THROWS_WITH(Measurer.var(*sparseH, num_shots),
+ Catch::Matchers::ContainsSubstring(
+ "SparseHamiltonian observables do "
+ "not support shot measurement."));
}
testSparseHObsMeasureShot();
diff --git a/pennylane_lightning/core/measurements/tests/mpi/Test_MeasurementsBaseMPI.cpp b/pennylane_lightning/core/measurements/tests/mpi/Test_MeasurementsBaseMPI.cpp
index ab9640677f..bd1d7fc474 100644
--- a/pennylane_lightning/core/measurements/tests/mpi/Test_MeasurementsBaseMPI.cpp
+++ b/pennylane_lightning/core/measurements/tests/mpi/Test_MeasurementsBaseMPI.cpp
@@ -11,7 +11,8 @@
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
-#include
+#include
+#include
#include "TestHelpers.hpp"
@@ -105,8 +106,9 @@ template void testProbabilities() {
<< StateVectorMPIToName::name) {
for (const auto &term : input) {
auto probabilities = Measurer.probs(term.first);
- REQUIRE_THAT(prob_local,
- Catch::Approx(probabilities).margin(1e-6));
+ REQUIRE_THAT(
+ prob_local,
+ Catch::Matchers::Approx(probabilities).margin(1e-6));
}
}
@@ -115,7 +117,7 @@ template void testProbabilities() {
std::size_t num_shots = 1000;
auto probabilities = Measurer.probs(num_shots);
REQUIRE_THAT(expected_prob,
- Catch::Approx(probabilities).margin(5e-2));
+ Catch::Matchers::Approx(probabilities).margin(5e-2));
}
DYNAMIC_SECTION(
@@ -129,7 +131,7 @@ template void testProbabilities() {
auto probabilities = Measurer.probs(wires, num_shots);
REQUIRE_THAT(expected_probs,
- Catch::Approx(probabilities).margin(5e-2));
+ Catch::Matchers::Approx(probabilities).margin(5e-2));
}
testProbabilities();
@@ -197,7 +199,8 @@ template void testProbabilitiesObs() {
auto prob_obs = Measurer_obs.probs(obs);
auto prob = Measurer.probs(std::vector({i}));
- REQUIRE_THAT(prob_obs, Catch::Approx(prob).margin(1e-6));
+ REQUIRE_THAT(prob_obs,
+ Catch::Matchers::Approx(prob).margin(1e-6));
}
}
@@ -215,7 +218,8 @@ template void testProbabilitiesObs() {
auto prob_obs = Measurer_obs.probs(obs);
auto prob = Measurer.probs(std::vector({i}));
- REQUIRE_THAT(prob_obs, Catch::Approx(prob).margin(1e-6));
+ REQUIRE_THAT(prob_obs,
+ Catch::Matchers::Approx(prob).margin(1e-6));
}
}
@@ -230,7 +234,8 @@ template void testProbabilitiesObs() {
auto prob_obs = Measurer_obs.probs(obs);
auto prob = Measurer.probs(std::vector({i}));
- REQUIRE_THAT(prob_obs, Catch::Approx(prob).margin(1e-6));
+ REQUIRE_THAT(prob_obs,
+ Catch::Matchers::Approx(prob).margin(1e-6));
}
}
@@ -247,7 +252,8 @@ template void testProbabilitiesObs() {
auto prob_obs = Measurer_obs.probs(obs);
auto prob = Measurer.probs(std::vector({i}));
- REQUIRE_THAT(prob_obs, Catch::Approx(prob).margin(1e-6));
+ REQUIRE_THAT(prob_obs,
+ Catch::Matchers::Approx(prob).margin(1e-6));
}
}
@@ -262,7 +268,8 @@ template void testProbabilitiesObs() {
auto prob_obs = Measurer_obs.probs(obs);
auto prob = Measurer.probs(std::vector({i}));
- REQUIRE_THAT(prob_obs, Catch::Approx(prob).margin(1e-6));
+ REQUIRE_THAT(prob_obs,
+ Catch::Matchers::Approx(prob).margin(1e-6));
}
}
@@ -287,7 +294,7 @@ template void testProbabilitiesObs() {
auto prob_obs = Measurer_obs.probs(*obs);
auto prob = Measurer.probs(std::vector({0, 1, 2}));
- REQUIRE_THAT(prob_obs, Catch::Approx(prob).margin(1e-6));
+ REQUIRE_THAT(prob_obs, Catch::Matchers::Approx(prob).margin(1e-6));
}
DYNAMIC_SECTION("Test TensorProd YHI"
@@ -312,7 +319,7 @@ template void testProbabilitiesObs() {
auto prob_obs = Measurer_obs.probs(*obs);
auto prob = Measurer.probs(std::vector({0, 1, 2}));
- REQUIRE_THAT(prob_obs, Catch::Approx(prob).margin(1e-6));
+ REQUIRE_THAT(prob_obs, Catch::Matchers::Approx(prob).margin(1e-6));
}
testProbabilitiesObs();
@@ -389,7 +396,8 @@ template void testProbabilitiesObsShots() {
auto prob_obs_shots = Measurer_obs_shots.probs(*obs, num_shots);
auto prob = Measurer.probs(std::vector({0, 1, 2}));
auto prob_all = mpi_manager.allgather(prob);
- REQUIRE_THAT(prob_obs_shots, Catch::Approx(prob_all).margin(5e-2));
+ REQUIRE_THAT(prob_obs_shots,
+ Catch::Matchers::Approx(prob_all).margin(5e-2));
}
DYNAMIC_SECTION("Test TensorProd YHI"
@@ -415,7 +423,8 @@ template void testProbabilitiesObsShots() {
auto prob_obs_shots = Measurer_obs_shots.probs(*obs, num_shots);
auto prob = Measurer.probs(std::vector({2, 1, 0}));
auto prob_all = mpi_manager.allgather(prob);
- REQUIRE_THAT(prob_obs_shots, Catch::Approx(prob_all).margin(5e-2));
+ REQUIRE_THAT(prob_obs_shots,
+ Catch::Matchers::Approx(prob_all).margin(5e-2));
}
testProbabilitiesObsShots();
@@ -1243,8 +1252,9 @@ template void testSamples() {
DYNAMIC_SECTION("No wires provided - "
<< StateVectorMPIToName::name) {
- REQUIRE_THAT(probabilities,
- Catch::Approx(expected_probabilities).margin(.05));
+ REQUIRE_THAT(
+ probabilities,
+ Catch::Matchers::Approx(expected_probabilities).margin(.05));
}
testSamples();
}
@@ -1387,8 +1397,9 @@ template void testSamplesCountsObs() {
probabilities[i] = counts[i] / (PrecisionT)num_samples;
}
- REQUIRE_THAT(probabilities,
- Catch::Approx(expected_probabilities).margin(.05));
+ REQUIRE_THAT(
+ probabilities,
+ Catch::Matchers::Approx(expected_probabilities).margin(.05));
}
DYNAMIC_SECTION("counts() without obs"
@@ -1420,8 +1431,9 @@ template void testSamplesCountsObs() {
probabilities[i] = counts[i] / (PrecisionT)num_samples;
}
- REQUIRE_THAT(probabilities,
- Catch::Approx(expected_probabilities).margin(.05));
+ REQUIRE_THAT(
+ probabilities,
+ Catch::Matchers::Approx(expected_probabilities).margin(.05));
}
testSamplesCountsObs();
diff --git a/pennylane_lightning/core/measurements/tests/mpi/runner_measurements_mpi.cpp b/pennylane_lightning/core/measurements/tests/mpi/runner_measurements_mpi.cpp
index b75b719a2c..757dbc9e5a 100644
--- a/pennylane_lightning/core/measurements/tests/mpi/runner_measurements_mpi.cpp
+++ b/pennylane_lightning/core/measurements/tests/mpi/runner_measurements_mpi.cpp
@@ -1,5 +1,5 @@
#define CATCH_CONFIG_RUNNER
-#include
+#include
#include
int main(int argc, char *argv[]) {
diff --git a/pennylane_lightning/core/measurements/tests/runner_measurements.cpp b/pennylane_lightning/core/measurements/tests/runner_measurements.cpp
index 4ed06df1f7..64ba13906f 100644
--- a/pennylane_lightning/core/measurements/tests/runner_measurements.cpp
+++ b/pennylane_lightning/core/measurements/tests/runner_measurements.cpp
@@ -1,2 +1,3 @@
-#define CATCH_CONFIG_MAIN
-#include
+#include
+
+int main(int argc, char *argv[]) { return Catch::Session().run(argc, argv); }
diff --git a/pennylane_lightning/core/observables/tests/Test_Observables.cpp b/pennylane_lightning/core/observables/tests/Test_Observables.cpp
index b8aa79646d..91a9d90a4e 100644
--- a/pennylane_lightning/core/observables/tests/Test_Observables.cpp
+++ b/pennylane_lightning/core/observables/tests/Test_Observables.cpp
@@ -17,7 +17,8 @@
#include "TypeList.hpp"
#include "Util.hpp" // TestVector
-#include
+#include
+#include
#include
#include
@@ -135,7 +136,7 @@ template void testNamedObsBase() {
REQUIRE_THROWS_WITH(
obs.applyInPlaceShots(state_vector, eigenValues, ob_wires),
- Catch::Matchers::Contains(
+ Catch::Matchers::ContainsSubstring(
"Provided NamedObs does not support shot measurement."));
auto ob = obs.getObs();
@@ -223,8 +224,9 @@ template void testHermitianObsBase() {
REQUIRE_THROWS_WITH(
obs.applyInPlaceShots(state_vector, eigenValues, ob_wires),
- Catch::Matchers::Contains("The matrix passed to HermitianObs "
- "is not a Hermitian matrix."));
+ Catch::Matchers::ContainsSubstring(
+ "The matrix passed to HermitianObs "
+ "is not a Hermitian matrix."));
}
testHermitianObsBase();
@@ -668,8 +670,9 @@ template void testSparseHamiltonianBase() {
REQUIRE_THROWS_WITH(
sparseH->applyInPlaceShots(state_vector, eigenValues, ob_wires),
- Catch::Matchers::Contains("SparseHamiltonian observables do "
- "not support shot measurement."));
+ Catch::Matchers::ContainsSubstring(
+ "SparseHamiltonian observables do "
+ "not support shot measurement."));
}
testSparseHamiltonianBase();
diff --git a/pennylane_lightning/core/observables/tests/mpi/Test_ObservablesMPI.cpp b/pennylane_lightning/core/observables/tests/mpi/Test_ObservablesMPI.cpp
index 5ee28d9083..3ae657ef30 100644
--- a/pennylane_lightning/core/observables/tests/mpi/Test_ObservablesMPI.cpp
+++ b/pennylane_lightning/core/observables/tests/mpi/Test_ObservablesMPI.cpp
@@ -11,7 +11,7 @@
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
-#include
+#include
#include
#include
diff --git a/pennylane_lightning/core/observables/tests/mpi/runner_observables_mpi.cpp b/pennylane_lightning/core/observables/tests/mpi/runner_observables_mpi.cpp
index 3bed64f9d3..1dfe3b5032 100644
--- a/pennylane_lightning/core/observables/tests/mpi/runner_observables_mpi.cpp
+++ b/pennylane_lightning/core/observables/tests/mpi/runner_observables_mpi.cpp
@@ -1,5 +1,5 @@
#define CATCH_CONFIG_RUNNER
-#include
+#include
#include
int main(int argc, char *argv[]) {
diff --git a/pennylane_lightning/core/observables/tests/runner_observables.cpp b/pennylane_lightning/core/observables/tests/runner_observables.cpp
index 4ed06df1f7..64ba13906f 100644
--- a/pennylane_lightning/core/observables/tests/runner_observables.cpp
+++ b/pennylane_lightning/core/observables/tests/runner_observables.cpp
@@ -1,2 +1,3 @@
-#define CATCH_CONFIG_MAIN
-#include
+#include
+
+int main(int argc, char *argv[]) { return Catch::Session().run(argc, argv); }
diff --git a/pennylane_lightning/core/simulators/base/tests/Test_StateVectorBase.cpp b/pennylane_lightning/core/simulators/base/tests/Test_StateVectorBase.cpp
index 405fcdc757..8180ba1d3b 100644
--- a/pennylane_lightning/core/simulators/base/tests/Test_StateVectorBase.cpp
+++ b/pennylane_lightning/core/simulators/base/tests/Test_StateVectorBase.cpp
@@ -15,7 +15,7 @@
#include
#include
-#include
+#include
#include "TestHelpers.hpp" // createZeroState, createRandomStateVectorData
#include "TypeList.hpp"
diff --git a/pennylane_lightning/core/simulators/base/tests/runner_base.cpp b/pennylane_lightning/core/simulators/base/tests/runner_base.cpp
index 4ed06df1f7..64ba13906f 100644
--- a/pennylane_lightning/core/simulators/base/tests/runner_base.cpp
+++ b/pennylane_lightning/core/simulators/base/tests/runner_base.cpp
@@ -1,2 +1,3 @@
-#define CATCH_CONFIG_MAIN
-#include
+#include
+
+int main(int argc, char *argv[]) { return Catch::Session().run(argc, argv); }
diff --git a/pennylane_lightning/core/simulators/lightning_gpu/algorithms/tests/Test_AdjointJacobianGPU.cpp b/pennylane_lightning/core/simulators/lightning_gpu/algorithms/tests/Test_AdjointJacobianGPU.cpp
index 29dad3318b..c9dcd7500b 100644
--- a/pennylane_lightning/core/simulators/lightning_gpu/algorithms/tests/Test_AdjointJacobianGPU.cpp
+++ b/pennylane_lightning/core/simulators/lightning_gpu/algorithms/tests/Test_AdjointJacobianGPU.cpp
@@ -4,7 +4,8 @@
#include
#include
-#include
+#include
+#include
#include "AdjointJacobianGPU.hpp"
#include "JacobianData.hpp"
diff --git a/pennylane_lightning/core/simulators/lightning_gpu/algorithms/tests/mpi/Test_AdjointJacobianGPUMPI.cpp b/pennylane_lightning/core/simulators/lightning_gpu/algorithms/tests/mpi/Test_AdjointJacobianGPUMPI.cpp
index 703bcab491..bda91fff83 100644
--- a/pennylane_lightning/core/simulators/lightning_gpu/algorithms/tests/mpi/Test_AdjointJacobianGPUMPI.cpp
+++ b/pennylane_lightning/core/simulators/lightning_gpu/algorithms/tests/mpi/Test_AdjointJacobianGPUMPI.cpp
@@ -18,7 +18,8 @@
#include
#include
-#include
+#include
+#include
#include "AdjointJacobianGPU.hpp"
#include "JacobianData.hpp"
diff --git a/pennylane_lightning/core/simulators/lightning_gpu/algorithms/tests/mpi/runner_lightning_gpu_algorithms_mpi.cpp b/pennylane_lightning/core/simulators/lightning_gpu/algorithms/tests/mpi/runner_lightning_gpu_algorithms_mpi.cpp
index b75b719a2c..757dbc9e5a 100644
--- a/pennylane_lightning/core/simulators/lightning_gpu/algorithms/tests/mpi/runner_lightning_gpu_algorithms_mpi.cpp
+++ b/pennylane_lightning/core/simulators/lightning_gpu/algorithms/tests/mpi/runner_lightning_gpu_algorithms_mpi.cpp
@@ -1,5 +1,5 @@
#define CATCH_CONFIG_RUNNER
-#include
+#include
#include
int main(int argc, char *argv[]) {
diff --git a/pennylane_lightning/core/simulators/lightning_gpu/algorithms/tests/runner_lightning_gpu_algorithms.cpp b/pennylane_lightning/core/simulators/lightning_gpu/algorithms/tests/runner_lightning_gpu_algorithms.cpp
index 4ed06df1f7..64ba13906f 100644
--- a/pennylane_lightning/core/simulators/lightning_gpu/algorithms/tests/runner_lightning_gpu_algorithms.cpp
+++ b/pennylane_lightning/core/simulators/lightning_gpu/algorithms/tests/runner_lightning_gpu_algorithms.cpp
@@ -1,2 +1,3 @@
-#define CATCH_CONFIG_MAIN
-#include
+#include
+
+int main(int argc, char *argv[]) { return Catch::Session().run(argc, argv); }
diff --git a/pennylane_lightning/core/simulators/lightning_gpu/catalyst/tests/Test_LightningGPUGradient.cpp b/pennylane_lightning/core/simulators/lightning_gpu/catalyst/tests/Test_LightningGPUGradient.cpp
index f914770522..1364a58547 100644
--- a/pennylane_lightning/core/simulators/lightning_gpu/catalyst/tests/Test_LightningGPUGradient.cpp
+++ b/pennylane_lightning/core/simulators/lightning_gpu/catalyst/tests/Test_LightningGPUGradient.cpp
@@ -13,7 +13,10 @@
// limitations under the License.
#include "LightningGPUSimulator.hpp"
-#include "catch2/catch.hpp"
+#include
+#include
+#include
+using Catch::Approx;
/// @cond DEV
namespace {
@@ -76,13 +79,13 @@ TEST_CASE("Test Gradient with Var", "[Gradient]") {
auto pz = sim->Observable(ObsId::PauliZ, {}, {q});
sim->Var(pz);
- REQUIRE_THROWS_WITH(
- sim->Gradient(gradients, trainParams),
- Catch::Contains("Unsupported measurements to compute gradient"));
+ REQUIRE_THROWS_WITH(sim->Gradient(gradients, trainParams),
+ Catch::Matchers::ContainsSubstring(
+ "Unsupported measurements to compute gradient"));
- REQUIRE_THROWS_WITH(
- sim->Gradient(gradients, {}),
- Catch::Contains("Unsupported measurements to compute gradient"));
+ REQUIRE_THROWS_WITH(sim->Gradient(gradients, {}),
+ Catch::Matchers::ContainsSubstring(
+ "Unsupported measurements to compute gradient"));
sim->StopTapeRecording();
}
diff --git a/pennylane_lightning/core/simulators/lightning_gpu/catalyst/tests/Test_LightningGPUMeasures.cpp b/pennylane_lightning/core/simulators/lightning_gpu/catalyst/tests/Test_LightningGPUMeasures.cpp
index 0d1f2a720c..8525b21d7d 100644
--- a/pennylane_lightning/core/simulators/lightning_gpu/catalyst/tests/Test_LightningGPUMeasures.cpp
+++ b/pennylane_lightning/core/simulators/lightning_gpu/catalyst/tests/Test_LightningGPUMeasures.cpp
@@ -19,7 +19,10 @@
#include "QuantumDevice.hpp"
#include "Types.h"
#include "Utils.hpp"
-#include "catch2/catch.hpp"
+#include
+#include
+#include
+using Catch::Approx;
#include "cmath"
/// @cond DEV
@@ -41,8 +44,9 @@ using LGPUSimulator = LightningGPUSimulator;
TEST_CASE("NameObs test with invalid number of wires", "[Measures]") {
std::unique_ptr sim = std::make_unique();
- REQUIRE_THROWS_WITH(sim->Observable(ObsId::PauliX, {}, {1}),
- Catch::Contains("Invalid number of wires"));
+ REQUIRE_THROWS_WITH(
+ sim->Observable(ObsId::PauliX, {}, {1}),
+ Catch::Matchers::ContainsSubstring("Invalid number of wires"));
}
TEST_CASE("NameObs test with invalid given wires for NamedObs", "[Measures]") {
@@ -50,15 +54,17 @@ TEST_CASE("NameObs test with invalid given wires for NamedObs", "[Measures]") {
sim->AllocateQubit();
- REQUIRE_THROWS_WITH(sim->Observable(ObsId::PauliX, {}, {1}),
- Catch::Contains("Invalid given wires"));
+ REQUIRE_THROWS_WITH(
+ sim->Observable(ObsId::PauliX, {}, {1}),
+ Catch::Matchers::ContainsSubstring("Invalid given wires"));
}
TEST_CASE("HermitianObs test with invalid number of wires", "[Measures]") {
std::unique_ptr sim = std::make_unique();
- REQUIRE_THROWS_WITH(sim->Observable(ObsId::Hermitian, {}, {1}),
- Catch::Contains("Invalid number of wires"));
+ REQUIRE_THROWS_WITH(
+ sim->Observable(ObsId::Hermitian, {}, {1}),
+ Catch::Matchers::ContainsSubstring("Invalid number of wires"));
}
TEST_CASE("HermitianObs test with invalid given wires for HermitianObs",
@@ -66,15 +72,16 @@ TEST_CASE("HermitianObs test with invalid given wires for HermitianObs",
std::unique_ptr sim = std::make_unique();
sim->AllocateQubit();
- REQUIRE_THROWS_WITH(sim->Observable(ObsId::Hermitian, {}, {1}),
- Catch::Contains("Invalid given wires"));
+ REQUIRE_THROWS_WITH(
+ sim->Observable(ObsId::Hermitian, {}, {1}),
+ Catch::Matchers::ContainsSubstring("Invalid given wires"));
}
TEST_CASE("Check an unsupported observable", "[Measures]") {
REQUIRE_THROWS_WITH(
Lightning::lookup_obs(
Lightning::simulator_observable_support, static_cast(10)),
- Catch::Contains(
+ Catch::Matchers::ContainsSubstring(
"The given observable is not supported by the simulator"));
}
@@ -187,8 +194,8 @@ TEST_CASE("Mid-circuit measurement test with invalid postselect value",
sim->NamedOperation("Hadamard", {}, {q}, false);
- REQUIRE_THROWS_WITH(sim->Measure(q, 2),
- Catch::Contains("Invalid postselect value"));
+ REQUIRE_THROWS_WITH(sim->Measure(q, 2), Catch::Matchers::ContainsSubstring(
+ "Invalid postselect value"));
}
TEST_CASE("Expval(ObsT) test with invalid key for cached observables",
@@ -196,7 +203,8 @@ TEST_CASE("Expval(ObsT) test with invalid key for cached observables",
std::unique_ptr sim = std::make_unique();
REQUIRE_THROWS_WITH(sim->Expval(0),
- Catch::Contains("Invalid key for cached observables"));
+ Catch::Matchers::ContainsSubstring(
+ "Invalid key for cached observables"));
}
TEST_CASE("Expval(NamedObs) test", "[Measures]") {
@@ -406,9 +414,9 @@ TEST_CASE("Expval(TensorProd(NamedObs[])) test", "[Measures]") {
ObsIdType tpxy = sim->TensorObservable({px, py});
ObsIdType tpxz = sim->TensorObservable({px, pz});
- REQUIRE_THROWS_WITH(
- sim->TensorObservable({px, py, pz}),
- Catch::Contains("All wires in observables must be disjoint."));
+ REQUIRE_THROWS_WITH(sim->TensorObservable({px, py, pz}),
+ Catch::Matchers::ContainsSubstring(
+ "All wires in observables must be disjoint."));
CHECK(sim->Expval(tpxy) == Approx(0.0).margin(1e-5));
CHECK(sim->Expval(tpxz) == Approx(-1.0).margin(1e-5));
@@ -1296,9 +1304,9 @@ TEST_CASE("State test with incorrect size", "[Measures]") {
std::vector> state(1U << (n - 1));
DataView, 1> view(state);
- REQUIRE_THROWS_WITH(
- sim->State(view),
- Catch::Contains("Invalid size for the pre-allocated state vector"));
+ REQUIRE_THROWS_WITH(sim->State(view),
+ Catch::Matchers::ContainsSubstring(
+ "Invalid size for the pre-allocated state vector"));
}
TEST_CASE("State test with numWires=4", "[Measures]") {
@@ -1345,21 +1353,23 @@ TEST_CASE("PartialProbs test with incorrect numWires and numAlloc",
REQUIRE_THROWS_WITH(
sim->PartialProbs(probs_view, {Qs[0], Qs[1], Qs[2], Qs[3], Qs[0]}),
- Catch::Contains("Invalid number of wires"));
+ Catch::Matchers::ContainsSubstring("Invalid number of wires"));
REQUIRE_THROWS_WITH(
sim->PartialProbs(probs_view, {Qs[0]}),
- Catch::Contains(
+ Catch::Matchers::ContainsSubstring(
"Invalid size for the pre-allocated partial-probabilities"));
REQUIRE_THROWS_WITH(
sim->Probs(probs_view),
- Catch::Contains("Invalid size for the pre-allocated probabilities"));
+ Catch::Matchers::ContainsSubstring(
+ "Invalid size for the pre-allocated probabilities"));
sim->ReleaseQubit(Qs[0]);
- REQUIRE_THROWS_WITH(sim->PartialProbs(probs_view, {Qs[0]}),
- Catch::Contains("Invalid given wires to measure"));
+ REQUIRE_THROWS_WITH(
+ sim->PartialProbs(probs_view, {Qs[0]}),
+ Catch::Matchers::ContainsSubstring("Invalid given wires to measure"));
}
TEST_CASE("Probs and PartialProbs tests with numWires=0-4", "[Measures]") {
@@ -1506,20 +1516,22 @@ TEST_CASE("PartialSample test with incorrect numWires and numAlloc",
REQUIRE_THROWS_WITH(
sim->PartialSample(view, {Qs[0], Qs[1], Qs[2], Qs[3], Qs[0]}),
- Catch::Contains("Invalid number of wires"));
+ Catch::Matchers::ContainsSubstring("Invalid number of wires"));
REQUIRE_THROWS_WITH(
sim->PartialSample(view, {Qs[0], Qs[1]}),
- Catch::Contains("Invalid size for the pre-allocated partial-samples"));
+ Catch::Matchers::ContainsSubstring(
+ "Invalid size for the pre-allocated partial-samples"));
- REQUIRE_THROWS_WITH(
- sim->Sample(view),
- Catch::Contains("Invalid size for the pre-allocated samples"));
+ REQUIRE_THROWS_WITH(sim->Sample(view),
+ Catch::Matchers::ContainsSubstring(
+ "Invalid size for the pre-allocated samples"));
sim->ReleaseQubit(Qs[0]);
- REQUIRE_THROWS_WITH(sim->PartialSample(view, {Qs[0]}),
- Catch::Contains("Invalid given wires to measure"));
+ REQUIRE_THROWS_WITH(
+ sim->PartialSample(view, {Qs[0]}),
+ Catch::Matchers::ContainsSubstring("Invalid given wires to measure"));
}
TEST_CASE("PartialCounts test with incorrect numWires and numAlloc",
@@ -1541,22 +1553,25 @@ TEST_CASE("PartialCounts test with incorrect numWires and numAlloc",
std::vector counts_vec(1);
DataView counts_view(counts_vec);
- REQUIRE_THROWS_WITH(sim->PartialCounts(eigvals_view, counts_view,
- {Qs[0], Qs[1], Qs[2], Qs[3], Qs[0]}),
- Catch::Contains("Invalid number of wires"));
+ REQUIRE_THROWS_WITH(
+ sim->PartialCounts(eigvals_view, counts_view,
+ {Qs[0], Qs[1], Qs[2], Qs[3], Qs[0]}),
+ Catch::Matchers::ContainsSubstring("Invalid number of wires"));
REQUIRE_THROWS_WITH(
sim->PartialCounts(eigvals_view, counts_view, {Qs[0]}),
- Catch::Contains("Invalid size for the pre-allocated partial-counts"));
+ Catch::Matchers::ContainsSubstring(
+ "Invalid size for the pre-allocated partial-counts"));
- REQUIRE_THROWS_WITH(
- sim->Counts(eigvals_view, counts_view),
- Catch::Contains("Invalid size for the pre-allocated counts"));
+ REQUIRE_THROWS_WITH(sim->Counts(eigvals_view, counts_view),
+ Catch::Matchers::ContainsSubstring(
+ "Invalid size for the pre-allocated counts"));
sim->ReleaseQubit(Qs[0]);
- REQUIRE_THROWS_WITH(sim->PartialCounts(eigvals_view, counts_view, {Qs[0]}),
- Catch::Contains("Invalid given wires to measure"));
+ REQUIRE_THROWS_WITH(
+ sim->PartialCounts(eigvals_view, counts_view, {Qs[0]}),
+ Catch::Matchers::ContainsSubstring("Invalid given wires to measure"));
}
TEST_CASE("Sample and PartialSample tests with numWires=0-4 shots=100",
diff --git a/pennylane_lightning/core/simulators/lightning_gpu/catalyst/tests/Test_LightningGPUSimulator.cpp b/pennylane_lightning/core/simulators/lightning_gpu/catalyst/tests/Test_LightningGPUSimulator.cpp
index 05c446498d..a543210da1 100644
--- a/pennylane_lightning/core/simulators/lightning_gpu/catalyst/tests/Test_LightningGPUSimulator.cpp
+++ b/pennylane_lightning/core/simulators/lightning_gpu/catalyst/tests/Test_LightningGPUSimulator.cpp
@@ -21,7 +21,8 @@
#include
#include
-#include
+#include
+#include
#include "LightningGPUSimulator.hpp"
#include "QuantumDevice.hpp"
@@ -78,13 +79,13 @@ TEST_CASE("LightningGPUSimulator::unit_tests", "[unit tests]") {
std::make_unique();
std::vector Qs = LGPUsim->AllocateQubits(1);
REQUIRE_NOTHROW(LGPUsim->StartTapeRecording());
- REQUIRE_THROWS_WITH(
- LGPUsim->StartTapeRecording(),
- Catch::Matchers::Contains("Cannot re-activate the cache manager"));
+ REQUIRE_THROWS_WITH(LGPUsim->StartTapeRecording(),
+ Catch::Matchers::ContainsSubstring(
+ "Cannot re-activate the cache manager"));
REQUIRE_NOTHROW(LGPUsim->StopTapeRecording());
REQUIRE_THROWS_WITH(
LGPUsim->StopTapeRecording(),
- Catch::Matchers::Contains(
+ Catch::Matchers::ContainsSubstring(
"Cannot stop an already stopped cache manager"));
}
}
@@ -753,14 +754,15 @@ TEST_CASE("LightningGPUSimulator::GateSet", "[GateSet]") {
constexpr std::size_t n_qubits = 2;
std::vector Qs = LGPUsim->AllocateQubits(n_qubits);
- REQUIRE_THROWS_WITH(
- LGPUsim->NamedOperation("Hadamard", {}, {Qs[0]}, false, {Qs[1]},
- {}),
- Catch::Contains("Controlled wires/values size mismatch"));
+ REQUIRE_THROWS_WITH(LGPUsim->NamedOperation("Hadamard", {}, {Qs[0]},
+ false, {Qs[1]}, {}),
+ Catch::Matchers::ContainsSubstring(
+ "Controlled wires/values size mismatch"));
std::vector> matrix(4, {0.0, 0.0});
REQUIRE_THROWS_WITH(
LGPUsim->MatrixOperation(matrix, {Qs[0]}, false, {Qs[1]}, {}),
- Catch::Contains("Controlled wires/values size mismatch"));
+ Catch::Matchers::ContainsSubstring(
+ "Controlled wires/values size mismatch"));
}
SECTION("Controlled GlobalPhase (multi-qubit)") {
@@ -873,14 +875,15 @@ TEST_CASE("LightningGPUSimulator::GateSet", "[GateSet]") {
constexpr std::size_t n_qubits = 2;
std::vector Qs = LGPUsim->AllocateQubits(n_qubits);
- REQUIRE_THROWS_WITH(
- LGPUsim->NamedOperation("PauliRot", {0.5}, {Qs[0]}, false, {}, {},
- {"X", "Y"}),
- Catch::Contains("PauliRot operation requires one string"));
+ REQUIRE_THROWS_WITH(LGPUsim->NamedOperation("PauliRot", {0.5}, {Qs[0]},
+ false, {}, {}, {"X", "Y"}),
+ Catch::Matchers::ContainsSubstring(
+ "PauliRot operation requires one string"));
- REQUIRE_THROWS_WITH(
- LGPUsim->NamedOperation("PauliRot", {0.5}, {Qs[0]}, false, {Qs[1]},
- {false}, {"XY"}),
- Catch::Contains("Controlled PauliRot is not supported"));
+ REQUIRE_THROWS_WITH(LGPUsim->NamedOperation("PauliRot", {0.5}, {Qs[0]},
+ false, {Qs[1]}, {false},
+ {"XY"}),
+ Catch::Matchers::ContainsSubstring(
+ "Controlled PauliRot is not supported"));
}
}
diff --git a/pennylane_lightning/core/simulators/lightning_gpu/catalyst/tests/runner_lightning_gpu_catalyst.cpp b/pennylane_lightning/core/simulators/lightning_gpu/catalyst/tests/runner_lightning_gpu_catalyst.cpp
index 4ed06df1f7..64ba13906f 100644
--- a/pennylane_lightning/core/simulators/lightning_gpu/catalyst/tests/runner_lightning_gpu_catalyst.cpp
+++ b/pennylane_lightning/core/simulators/lightning_gpu/catalyst/tests/runner_lightning_gpu_catalyst.cpp
@@ -1,2 +1,3 @@
-#define CATCH_CONFIG_MAIN
-#include
+#include
+
+int main(int argc, char *argv[]) { return Catch::Session().run(argc, argv); }
diff --git a/pennylane_lightning/core/simulators/lightning_gpu/gates/tests/Test_StateVectorCudaManaged_Generators.cpp b/pennylane_lightning/core/simulators/lightning_gpu/gates/tests/Test_StateVectorCudaManaged_Generators.cpp
index d8c2a66ff6..393a58f4a6 100644
--- a/pennylane_lightning/core/simulators/lightning_gpu/gates/tests/Test_StateVectorCudaManaged_Generators.cpp
+++ b/pennylane_lightning/core/simulators/lightning_gpu/gates/tests/Test_StateVectorCudaManaged_Generators.cpp
@@ -17,7 +17,8 @@
#include
#include
-#include
+#include
+#include
#include "StateVectorCudaManaged.hpp"
#include "TestHelpers.hpp"
diff --git a/pennylane_lightning/core/simulators/lightning_gpu/gates/tests/Test_StateVectorCudaManaged_NonParam.cpp b/pennylane_lightning/core/simulators/lightning_gpu/gates/tests/Test_StateVectorCudaManaged_NonParam.cpp
index 725539e699..afa134d83f 100644
--- a/pennylane_lightning/core/simulators/lightning_gpu/gates/tests/Test_StateVectorCudaManaged_NonParam.cpp
+++ b/pennylane_lightning/core/simulators/lightning_gpu/gates/tests/Test_StateVectorCudaManaged_NonParam.cpp
@@ -21,7 +21,8 @@
#include
#include
-#include
+#include
+#include
#include "StateVectorCudaManaged.hpp"
#include "cuGateCache.hpp"
diff --git a/pennylane_lightning/core/simulators/lightning_gpu/gates/tests/Test_StateVectorCudaManaged_Param.cpp b/pennylane_lightning/core/simulators/lightning_gpu/gates/tests/Test_StateVectorCudaManaged_Param.cpp
index 39de53ac1c..ce4a07b56a 100644
--- a/pennylane_lightning/core/simulators/lightning_gpu/gates/tests/Test_StateVectorCudaManaged_Param.cpp
+++ b/pennylane_lightning/core/simulators/lightning_gpu/gates/tests/Test_StateVectorCudaManaged_Param.cpp
@@ -21,7 +21,8 @@
#include
#include
-#include
+#include
+#include
#include "Gates.hpp"
#include "TestHelpers.hpp"
diff --git a/pennylane_lightning/core/simulators/lightning_gpu/gates/tests/mpi/Test_StateVectorCudaMPI_Generators.cpp b/pennylane_lightning/core/simulators/lightning_gpu/gates/tests/mpi/Test_StateVectorCudaMPI_Generators.cpp
index 164fed7f01..aee834b5e1 100644
--- a/pennylane_lightning/core/simulators/lightning_gpu/gates/tests/mpi/Test_StateVectorCudaMPI_Generators.cpp
+++ b/pennylane_lightning/core/simulators/lightning_gpu/gates/tests/mpi/Test_StateVectorCudaMPI_Generators.cpp
@@ -17,7 +17,7 @@
#include
#include
-#include
+#include
#include "MPIManagerGPU.hpp"
#include "StateVectorCudaMPI.hpp"
diff --git a/pennylane_lightning/core/simulators/lightning_gpu/gates/tests/mpi/Test_StateVectorCudaMPI_NonParam.cpp b/pennylane_lightning/core/simulators/lightning_gpu/gates/tests/mpi/Test_StateVectorCudaMPI_NonParam.cpp
index 672975ea86..f7996ba3e5 100644
--- a/pennylane_lightning/core/simulators/lightning_gpu/gates/tests/mpi/Test_StateVectorCudaMPI_NonParam.cpp
+++ b/pennylane_lightning/core/simulators/lightning_gpu/gates/tests/mpi/Test_StateVectorCudaMPI_NonParam.cpp
@@ -20,7 +20,8 @@
#include
#include
-#include
+#include
+#include
#include
#include "DevTag.hpp"
diff --git a/pennylane_lightning/core/simulators/lightning_gpu/gates/tests/mpi/Test_StateVectorCudaMPI_Param.cpp b/pennylane_lightning/core/simulators/lightning_gpu/gates/tests/mpi/Test_StateVectorCudaMPI_Param.cpp
index db8f0ef4b5..e969114a62 100644
--- a/pennylane_lightning/core/simulators/lightning_gpu/gates/tests/mpi/Test_StateVectorCudaMPI_Param.cpp
+++ b/pennylane_lightning/core/simulators/lightning_gpu/gates/tests/mpi/Test_StateVectorCudaMPI_Param.cpp
@@ -19,7 +19,8 @@
#include
#include
-#include
+#include
+#include
#include
#include "cuGateCache.hpp"
diff --git a/pennylane_lightning/core/simulators/lightning_gpu/gates/tests/mpi/mpi_runner_lightning_gpu_gates.cpp b/pennylane_lightning/core/simulators/lightning_gpu/gates/tests/mpi/mpi_runner_lightning_gpu_gates.cpp
index b75b719a2c..1dfe3b5032 100644
--- a/pennylane_lightning/core/simulators/lightning_gpu/gates/tests/mpi/mpi_runner_lightning_gpu_gates.cpp
+++ b/pennylane_lightning/core/simulators/lightning_gpu/gates/tests/mpi/mpi_runner_lightning_gpu_gates.cpp
@@ -1,5 +1,5 @@
#define CATCH_CONFIG_RUNNER
-#include
+#include
#include
int main(int argc, char *argv[]) {
@@ -7,4 +7,4 @@ int main(int argc, char *argv[]) {
int result = Catch::Session().run(argc, argv);
MPI_Finalize();
return result;
-}
\ No newline at end of file
+}
diff --git a/pennylane_lightning/core/simulators/lightning_gpu/gates/tests/runner_lightning_gpu_gates.cpp b/pennylane_lightning/core/simulators/lightning_gpu/gates/tests/runner_lightning_gpu_gates.cpp
index 4ed06df1f7..64ba13906f 100644
--- a/pennylane_lightning/core/simulators/lightning_gpu/gates/tests/runner_lightning_gpu_gates.cpp
+++ b/pennylane_lightning/core/simulators/lightning_gpu/gates/tests/runner_lightning_gpu_gates.cpp
@@ -1,2 +1,3 @@
-#define CATCH_CONFIG_MAIN
-#include
+#include
+
+int main(int argc, char *argv[]) { return Catch::Session().run(argc, argv); }
diff --git a/pennylane_lightning/core/simulators/lightning_gpu/measurements/tests/Test_StateVectorCudaManaged_Expval.cpp b/pennylane_lightning/core/simulators/lightning_gpu/measurements/tests/Test_StateVectorCudaManaged_Expval.cpp
index 6539d34116..3904d8e334 100644
--- a/pennylane_lightning/core/simulators/lightning_gpu/measurements/tests/Test_StateVectorCudaManaged_Expval.cpp
+++ b/pennylane_lightning/core/simulators/lightning_gpu/measurements/tests/Test_StateVectorCudaManaged_Expval.cpp
@@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-#include
+#include
#include
#include
diff --git a/pennylane_lightning/core/simulators/lightning_gpu/measurements/tests/Test_StateVectorCudaManaged_Measure.cpp b/pennylane_lightning/core/simulators/lightning_gpu/measurements/tests/Test_StateVectorCudaManaged_Measure.cpp
index 4f3efaade5..63fc464b68 100644
--- a/pennylane_lightning/core/simulators/lightning_gpu/measurements/tests/Test_StateVectorCudaManaged_Measure.cpp
+++ b/pennylane_lightning/core/simulators/lightning_gpu/measurements/tests/Test_StateVectorCudaManaged_Measure.cpp
@@ -19,7 +19,8 @@
#include
#include
-#include
+#include
+#include
#include "MeasurementsGPU.hpp"
#include "StateVectorCudaManaged.hpp"
@@ -74,17 +75,20 @@ TEMPLATE_TEST_CASE("Expected Values", "[Measurements]", float, double) {
operations_list = {PauliX, PauliX, PauliX};
exp_values = Measurer.expval(operations_list, wires_list);
exp_values_ref = {0.49272486, 0.42073549, 0.28232124};
- REQUIRE_THAT(exp_values, Catch::Approx(exp_values_ref).margin(1e-6));
+ REQUIRE_THAT(exp_values,
+ Catch::Matchers::Approx(exp_values_ref).margin(1e-6));
operations_list = {PauliY, PauliY, PauliY};
exp_values = Measurer.expval(operations_list, wires_list);
exp_values_ref = {-0.64421768, -0.47942553, -0.29552020};
- REQUIRE_THAT(exp_values, Catch::Approx(exp_values_ref).margin(1e-6));
+ REQUIRE_THAT(exp_values,
+ Catch::Matchers::Approx(exp_values_ref).margin(1e-6));
operations_list = {PauliZ, PauliZ, PauliZ};
exp_values = Measurer.expval(operations_list, wires_list);
exp_values_ref = {0.58498357, 0.77015115, 0.91266780};
- REQUIRE_THAT(exp_values, Catch::Approx(exp_values_ref).margin(1e-6));
+ REQUIRE_THAT(exp_values,
+ Catch::Matchers::Approx(exp_values_ref).margin(1e-6));
}
SECTION("Testing list of operators defined by its name:") {
@@ -96,17 +100,20 @@ TEMPLATE_TEST_CASE("Expected Values", "[Measurements]", float, double) {
operations_list = {"PauliX", "PauliX", "PauliX"};
exp_values = Measurer.expval(operations_list, wires_list);
exp_values_ref = {0.49272486, 0.42073549, 0.28232124};
- REQUIRE_THAT(exp_values, Catch::Approx(exp_values_ref).margin(1e-6));
+ REQUIRE_THAT(exp_values,
+ Catch::Matchers::Approx(exp_values_ref).margin(1e-6));
operations_list = {"PauliY", "PauliY", "PauliY"};
exp_values = Measurer.expval(operations_list, wires_list);
exp_values_ref = {-0.64421768, -0.47942553, -0.29552020};
- REQUIRE_THAT(exp_values, Catch::Approx(exp_values_ref).margin(1e-6));
+ REQUIRE_THAT(exp_values,
+ Catch::Matchers::Approx(exp_values_ref).margin(1e-6));
operations_list = {"PauliZ", "PauliZ", "PauliZ"};
exp_values = Measurer.expval(operations_list, wires_list);
exp_values_ref = {0.58498357, 0.77015115, 0.91266780};
- REQUIRE_THAT(exp_values, Catch::Approx(exp_values_ref).margin(1e-6));
+ REQUIRE_THAT(exp_values,
+ Catch::Matchers::Approx(exp_values_ref).margin(1e-6));
}
SECTION("Catch failures caused by unsupported named gates") {
@@ -217,17 +224,20 @@ TEMPLATE_TEST_CASE("Variances", "[Measurements]", float, double) {
operations_list = {PauliX, PauliX, PauliX};
variances = Measurer.var(operations_list, wires_list);
variances_ref = {0.7572222, 0.8229816, 0.9202947};
- REQUIRE_THAT(variances, Catch::Approx(variances_ref).margin(1e-6));
+ REQUIRE_THAT(variances,
+ Catch::Matchers::Approx(variances_ref).margin(1e-6));
operations_list = {PauliY, PauliY, PauliY};
variances = Measurer.var(operations_list, wires_list);
variances_ref = {0.5849835, 0.7701511, 0.9126678};
- REQUIRE_THAT(variances, Catch::Approx(variances_ref).margin(1e-6));
+ REQUIRE_THAT(variances,
+ Catch::Matchers::Approx(variances_ref).margin(1e-6));
operations_list = {PauliZ, PauliZ, PauliZ};
variances = Measurer.var(operations_list, wires_list);
variances_ref = {0.6577942, 0.4068672, 0.1670374};
- REQUIRE_THAT(variances, Catch::Approx(variances_ref).margin(1e-6));
+ REQUIRE_THAT(variances,
+ Catch::Matchers::Approx(variances_ref).margin(1e-6));
}
SECTION("Testing list of operators defined by its name:") {
@@ -239,17 +249,20 @@ TEMPLATE_TEST_CASE("Variances", "[Measurements]", float, double) {
operations_list = {"PauliX", "PauliX", "PauliX"};
variances = Measurer.var(operations_list, wires_list);
variances_ref = {0.7572222, 0.8229816, 0.9202947};
- REQUIRE_THAT(variances, Catch::Approx(variances_ref).margin(1e-6));
+ REQUIRE_THAT(variances,
+ Catch::Matchers::Approx(variances_ref).margin(1e-6));
operations_list = {"PauliY", "PauliY", "PauliY"};
variances = Measurer.var(operations_list, wires_list);
variances_ref = {0.5849835, 0.7701511, 0.9126678};
- REQUIRE_THAT(variances, Catch::Approx(variances_ref).margin(1e-6));
+ REQUIRE_THAT(variances,
+ Catch::Matchers::Approx(variances_ref).margin(1e-6));
operations_list = {"PauliZ", "PauliZ", "PauliZ"};
variances = Measurer.var(operations_list, wires_list);
variances_ref = {0.6577942, 0.4068672, 0.1670374};
- REQUIRE_THAT(variances, Catch::Approx(variances_ref).margin(1e-6));
+ REQUIRE_THAT(variances,
+ Catch::Matchers::Approx(variances_ref).margin(1e-6));
}
}
@@ -271,7 +284,7 @@ TEMPLATE_TEST_CASE("Probabilities", "[Measures]", float, double) {
for (const auto &term : input) {
auto probabilities = m.probs(term.first);
REQUIRE_THAT(term.second,
- Catch::Approx(probabilities).margin(1e-6));
+ Catch::Matchers::Approx(probabilities).margin(1e-6));
}
}
}
\ No newline at end of file
diff --git a/pennylane_lightning/core/simulators/lightning_gpu/measurements/tests/Test_StateVectorCudaManaged_Var.cpp b/pennylane_lightning/core/simulators/lightning_gpu/measurements/tests/Test_StateVectorCudaManaged_Var.cpp
index deccedee0c..3bcf99c315 100644
--- a/pennylane_lightning/core/simulators/lightning_gpu/measurements/tests/Test_StateVectorCudaManaged_Var.cpp
+++ b/pennylane_lightning/core/simulators/lightning_gpu/measurements/tests/Test_StateVectorCudaManaged_Var.cpp
@@ -19,7 +19,9 @@
#include
#include
-#include
+#include
+#include
+using Catch::Approx;
#include "MeasurementsGPU.hpp"
#include "ObservablesGPU.hpp"
diff --git a/pennylane_lightning/core/simulators/lightning_gpu/measurements/tests/mpi/Test_StateVectorCudaMPI_Expval.cpp b/pennylane_lightning/core/simulators/lightning_gpu/measurements/tests/mpi/Test_StateVectorCudaMPI_Expval.cpp
index 739e24da94..9af30449dc 100644
--- a/pennylane_lightning/core/simulators/lightning_gpu/measurements/tests/mpi/Test_StateVectorCudaMPI_Expval.cpp
+++ b/pennylane_lightning/core/simulators/lightning_gpu/measurements/tests/mpi/Test_StateVectorCudaMPI_Expval.cpp
@@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-#include
+#include
#include
#include
diff --git a/pennylane_lightning/core/simulators/lightning_gpu/measurements/tests/mpi/Test_StateVectorCudaMPI_Measure.cpp b/pennylane_lightning/core/simulators/lightning_gpu/measurements/tests/mpi/Test_StateVectorCudaMPI_Measure.cpp
index 8df30cb776..35d92692a5 100644
--- a/pennylane_lightning/core/simulators/lightning_gpu/measurements/tests/mpi/Test_StateVectorCudaMPI_Measure.cpp
+++ b/pennylane_lightning/core/simulators/lightning_gpu/measurements/tests/mpi/Test_StateVectorCudaMPI_Measure.cpp
@@ -19,7 +19,8 @@
#include
#include
-#include
+#include
+#include
#include "MPIManagerGPU.hpp"
#include "MeasurementsGPU.hpp"
@@ -119,17 +120,20 @@ TEMPLATE_TEST_CASE("Expected Values", "[MeasurementsMPI]", float, double) {
operations_list = {PauliX, PauliX, PauliX};
exp_values = Measurer.expval(operations_list, wires_list);
exp_values_ref = {0.49272486, 0.42073549, 0.28232124};
- REQUIRE_THAT(exp_values, Catch::Approx(exp_values_ref).margin(1e-6));
+ REQUIRE_THAT(exp_values,
+ Catch::Matchers::Approx(exp_values_ref).margin(1e-6));
operations_list = {PauliY, PauliY, PauliY};
exp_values = Measurer.expval(operations_list, wires_list);
exp_values_ref = {-0.64421768, -0.47942553, -0.29552020};
- REQUIRE_THAT(exp_values, Catch::Approx(exp_values_ref).margin(1e-6));
+ REQUIRE_THAT(exp_values,
+ Catch::Matchers::Approx(exp_values_ref).margin(1e-6));
operations_list = {PauliZ, PauliZ, PauliZ};
exp_values = Measurer.expval(operations_list, wires_list);
exp_values_ref = {0.58498357, 0.77015115, 0.91266780};
- REQUIRE_THAT(exp_values, Catch::Approx(exp_values_ref).margin(1e-6));
+ REQUIRE_THAT(exp_values,
+ Catch::Matchers::Approx(exp_values_ref).margin(1e-6));
}
SECTION("Testing list of operators defined by its name:") {
@@ -148,17 +152,20 @@ TEMPLATE_TEST_CASE("Expected Values", "[MeasurementsMPI]", float, double) {
operations_list = {"PauliX", "PauliX", "PauliX"};
exp_values = Measurer.expval(operations_list, wires_list);
exp_values_ref = {0.49272486, 0.42073549, 0.28232124};
- REQUIRE_THAT(exp_values, Catch::Approx(exp_values_ref).margin(1e-6));
+ REQUIRE_THAT(exp_values,
+ Catch::Matchers::Approx(exp_values_ref).margin(1e-6));
operations_list = {"PauliY", "PauliY", "PauliY"};
exp_values = Measurer.expval(operations_list, wires_list);
exp_values_ref = {-0.64421768, -0.47942553, -0.29552020};
- REQUIRE_THAT(exp_values, Catch::Approx(exp_values_ref).margin(1e-6));
+ REQUIRE_THAT(exp_values,
+ Catch::Matchers::Approx(exp_values_ref).margin(1e-6));
operations_list = {"PauliZ", "PauliZ", "PauliZ"};
exp_values = Measurer.expval(operations_list, wires_list);
exp_values_ref = {0.58498357, 0.77015115, 0.91266780};
- REQUIRE_THAT(exp_values, Catch::Approx(exp_values_ref).margin(1e-6));
+ REQUIRE_THAT(exp_values,
+ Catch::Matchers::Approx(exp_values_ref).margin(1e-6));
}
SECTION("Catch failures caused by unsupported named gates") {
@@ -369,17 +376,20 @@ TEMPLATE_TEST_CASE("Variances", "[MeasurementsMPI]", double) {
operations_list = {PauliX, PauliX, PauliX};
variances = Measurer.var(operations_list, wires_list);
variances_ref = {0.7572222, 0.8229816, 0.9202947};
- REQUIRE_THAT(variances, Catch::Approx(variances_ref).margin(1e-6));
+ REQUIRE_THAT(variances,
+ Catch::Matchers::Approx(variances_ref).margin(1e-6));
operations_list = {PauliY, PauliY, PauliY};
variances = Measurer.var(operations_list, wires_list);
variances_ref = {0.5849835, 0.7701511, 0.9126678};
- REQUIRE_THAT(variances, Catch::Approx(variances_ref).margin(1e-6));
+ REQUIRE_THAT(variances,
+ Catch::Matchers::Approx(variances_ref).margin(1e-6));
operations_list = {PauliZ, PauliZ, PauliZ};
variances = Measurer.var(operations_list, wires_list);
variances_ref = {0.6577942, 0.4068672, 0.1670374};
- REQUIRE_THAT(variances, Catch::Approx(variances_ref).margin(1e-6));
+ REQUIRE_THAT(variances,
+ Catch::Matchers::Approx(variances_ref).margin(1e-6));
}
SECTION("Testing list of operators defined by its name:") {
@@ -393,17 +403,20 @@ TEMPLATE_TEST_CASE("Variances", "[MeasurementsMPI]", double) {
operations_list = {"PauliX", "PauliX", "PauliX"};
variances = Measurer.var(operations_list, wires_list);
variances_ref = {0.7572222, 0.8229816, 0.9202947};
- REQUIRE_THAT(variances, Catch::Approx(variances_ref).margin(1e-6));
+ REQUIRE_THAT(variances,
+ Catch::Matchers::Approx(variances_ref).margin(1e-6));
operations_list = {"PauliY", "PauliY", "PauliY"};
variances = Measurer.var(operations_list, wires_list);
variances_ref = {0.5849835, 0.7701511, 0.9126678};
- REQUIRE_THAT(variances, Catch::Approx(variances_ref).margin(1e-6));
+ REQUIRE_THAT(variances,
+ Catch::Matchers::Approx(variances_ref).margin(1e-6));
operations_list = {"PauliZ", "PauliZ", "PauliZ"};
variances = Measurer.var(operations_list, wires_list);
variances_ref = {0.6577942, 0.4068672, 0.1670374};
- REQUIRE_THAT(variances, Catch::Approx(variances_ref).margin(1e-6));
+ REQUIRE_THAT(variances,
+ Catch::Matchers::Approx(variances_ref).margin(1e-6));
}
}
@@ -453,7 +466,8 @@ TEMPLATE_TEST_CASE("Probabilities", "[MeasuresMPI]", double) {
auto m = MeasurementsMPI(sv);
for (const auto &term : input) {
auto probabilities = m.probs(term.first);
- REQUIRE_THAT(prob_local, Catch::Approx(probabilities).margin(1e-6));
+ REQUIRE_THAT(prob_local,
+ Catch::Matchers::Approx(probabilities).margin(1e-6));
}
}
}
diff --git a/pennylane_lightning/core/simulators/lightning_gpu/measurements/tests/mpi/Test_StateVectorCudaMPI_Var.cpp b/pennylane_lightning/core/simulators/lightning_gpu/measurements/tests/mpi/Test_StateVectorCudaMPI_Var.cpp
index 2a521bcdba..9a36c8162f 100644
--- a/pennylane_lightning/core/simulators/lightning_gpu/measurements/tests/mpi/Test_StateVectorCudaMPI_Var.cpp
+++ b/pennylane_lightning/core/simulators/lightning_gpu/measurements/tests/mpi/Test_StateVectorCudaMPI_Var.cpp
@@ -19,7 +19,9 @@
#include
#include
-#include
+#include
+#include
+using Catch::Approx;
#include "MeasurementsGPU.hpp"
#include "MeasurementsGPUMPI.hpp"
diff --git a/pennylane_lightning/core/simulators/lightning_gpu/measurements/tests/mpi/runner_lightning_gpu_measurements_mpi.cpp b/pennylane_lightning/core/simulators/lightning_gpu/measurements/tests/mpi/runner_lightning_gpu_measurements_mpi.cpp
index b75b719a2c..757dbc9e5a 100644
--- a/pennylane_lightning/core/simulators/lightning_gpu/measurements/tests/mpi/runner_lightning_gpu_measurements_mpi.cpp
+++ b/pennylane_lightning/core/simulators/lightning_gpu/measurements/tests/mpi/runner_lightning_gpu_measurements_mpi.cpp
@@ -1,5 +1,5 @@
#define CATCH_CONFIG_RUNNER
-#include
+#include
#include
int main(int argc, char *argv[]) {
diff --git a/pennylane_lightning/core/simulators/lightning_gpu/measurements/tests/runner_lightning_gpu_measurements.cpp b/pennylane_lightning/core/simulators/lightning_gpu/measurements/tests/runner_lightning_gpu_measurements.cpp
index 4ed06df1f7..64ba13906f 100644
--- a/pennylane_lightning/core/simulators/lightning_gpu/measurements/tests/runner_lightning_gpu_measurements.cpp
+++ b/pennylane_lightning/core/simulators/lightning_gpu/measurements/tests/runner_lightning_gpu_measurements.cpp
@@ -1,2 +1,3 @@
-#define CATCH_CONFIG_MAIN
-#include
+#include
+
+int main(int argc, char *argv[]) { return Catch::Session().run(argc, argv); }
diff --git a/pennylane_lightning/core/simulators/lightning_gpu/observables/tests/Test_ObservablesGPU.cpp b/pennylane_lightning/core/simulators/lightning_gpu/observables/tests/Test_ObservablesGPU.cpp
index f8850ef3ff..0ac9a34dc9 100644
--- a/pennylane_lightning/core/simulators/lightning_gpu/observables/tests/Test_ObservablesGPU.cpp
+++ b/pennylane_lightning/core/simulators/lightning_gpu/observables/tests/Test_ObservablesGPU.cpp
@@ -14,7 +14,7 @@
#include "ObservablesGPU.hpp"
#include "TestHelpers.hpp"
-#include
+#include
/// @cond DEV
namespace {
diff --git a/pennylane_lightning/core/simulators/lightning_gpu/observables/tests/mpi/Test_ObservablesGPUMPI.cpp b/pennylane_lightning/core/simulators/lightning_gpu/observables/tests/mpi/Test_ObservablesGPUMPI.cpp
index 0e1e1788be..ddfe0bd105 100644
--- a/pennylane_lightning/core/simulators/lightning_gpu/observables/tests/mpi/Test_ObservablesGPUMPI.cpp
+++ b/pennylane_lightning/core/simulators/lightning_gpu/observables/tests/mpi/Test_ObservablesGPUMPI.cpp
@@ -11,7 +11,7 @@
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
-#include
+#include
#include "MPIManagerGPU.hpp"
#include "ObservablesGPU.hpp"
diff --git a/pennylane_lightning/core/simulators/lightning_gpu/observables/tests/mpi/runner_lightning_gpu_observables_mpi.cpp b/pennylane_lightning/core/simulators/lightning_gpu/observables/tests/mpi/runner_lightning_gpu_observables_mpi.cpp
index b75b719a2c..757dbc9e5a 100644
--- a/pennylane_lightning/core/simulators/lightning_gpu/observables/tests/mpi/runner_lightning_gpu_observables_mpi.cpp
+++ b/pennylane_lightning/core/simulators/lightning_gpu/observables/tests/mpi/runner_lightning_gpu_observables_mpi.cpp
@@ -1,5 +1,5 @@
#define CATCH_CONFIG_RUNNER
-#include
+#include
#include
int main(int argc, char *argv[]) {
diff --git a/pennylane_lightning/core/simulators/lightning_gpu/observables/tests/runner_lightning_gpu_observables.cpp b/pennylane_lightning/core/simulators/lightning_gpu/observables/tests/runner_lightning_gpu_observables.cpp
index 4ed06df1f7..64ba13906f 100644
--- a/pennylane_lightning/core/simulators/lightning_gpu/observables/tests/runner_lightning_gpu_observables.cpp
+++ b/pennylane_lightning/core/simulators/lightning_gpu/observables/tests/runner_lightning_gpu_observables.cpp
@@ -1,2 +1,3 @@
-#define CATCH_CONFIG_MAIN
-#include
+#include
+
+int main(int argc, char *argv[]) { return Catch::Session().run(argc, argv); }
diff --git a/pennylane_lightning/core/simulators/lightning_gpu/tests/Test_StateVectorCudaManaged.cpp b/pennylane_lightning/core/simulators/lightning_gpu/tests/Test_StateVectorCudaManaged.cpp
index a50c791926..369cbaa5e2 100644
--- a/pennylane_lightning/core/simulators/lightning_gpu/tests/Test_StateVectorCudaManaged.cpp
+++ b/pennylane_lightning/core/simulators/lightning_gpu/tests/Test_StateVectorCudaManaged.cpp
@@ -19,7 +19,9 @@
#include
#include
-#include
+#include