|
| 1 | +#include "Definitions.hpp" |
| 2 | +#include "algorithms/StatePreparation.hpp" |
| 3 | +#include "dd/Package.hpp" |
| 4 | +#include "ir/QuantumComputation.hpp" |
| 5 | + |
| 6 | +#include <cmath> |
| 7 | +#include <complex> |
| 8 | +#include <gtest/gtest.h> |
| 9 | +#include <sstream> |
| 10 | +#include <string> |
| 11 | +#include <vector> |
| 12 | + |
| 13 | +class StatePreparation |
| 14 | + : public testing::TestWithParam<std::vector<std::complex<double>>> { |
| 15 | +protected: |
| 16 | + std::vector<std::complex<double>> amplitudes{}; |
| 17 | + |
| 18 | + void TearDown() override {} |
| 19 | + void SetUp() override { amplitudes = GetParam(); } |
| 20 | +}; |
| 21 | + |
| 22 | +INSTANTIATE_TEST_SUITE_P( |
| 23 | + StatePreparation, StatePreparation, |
| 24 | + testing::Values(std::vector{std::complex{1 / std::sqrt(2)}, |
| 25 | + std::complex{-1 / std::sqrt(2)}}, |
| 26 | + std::vector<std::complex<double>>{ |
| 27 | + 0, std::complex{1 / std::sqrt(2)}, |
| 28 | + std::complex{-1 / std::sqrt(2)}, 0}), |
| 29 | + [](const testing::TestParamInfo<StatePreparation::ParamType>& inf) { |
| 30 | + const std::vector<std::complex<double>> vector = inf.param; |
| 31 | + std::stringstream ss{}; |
| 32 | + ss << "State Preparation with amplitudes: ["; |
| 33 | + for (const auto cmplx : vector) { |
| 34 | + ss << ", (" + std::to_string(cmplx.real()) + "," + |
| 35 | + std::to_string(cmplx.imag()) + ")"; |
| 36 | + } |
| 37 | + return ss.str(); |
| 38 | + }); |
| 39 | + |
| 40 | +TEST_P(StatePreparation, StatePreparationCircuitSimulation) { |
| 41 | + ASSERT_NO_THROW({ auto qc = qc::createStatePreparationCircuit(amplitudes); }); |
| 42 | +} |
| 43 | + |
| 44 | +TEST_P(StatePreparation, StatePreparationCircuit) {} |
0 commit comments