@@ -203,7 +203,9 @@ TEST_F(Apply1QGateTest, RotationXY)
203203 psi.ApplyRotationZ (qubit, -phi);
204204 psi.ApplyRotationX (qubit, -theta);
205205 psi.ApplyRotationZ (qubit, phi);
206- ASSERT_TRUE ( psi.ComputeOverlap (psi_0).real () < 1 .-accepted_error_);
206+ ASSERT_TRUE ( std::abs (psi.ComputeOverlap (psi_0).real () - 1 ) < accepted_error_);
207+ ASSERT_TRUE ( std::abs (psi.ComputeOverlap (psi_0).imag () - 0 ) < accepted_error_);
208+ ASSERT_TRUE ( psi.ComputeOverlap (psi_0).real () > 1 .-accepted_error_);
207209 // Apply rotation in the XY plane and then cancel it with two rotations.
208210 phi = 1.1 ;
209211 theta = 0.13 ;
@@ -212,20 +214,23 @@ TEST_F(Apply1QGateTest, RotationXY)
212214 psi.ApplyRotationZ (qubit, -phi);
213215 psi.ApplyRotationX (qubit, -theta);
214216 psi.ApplyRotationZ (qubit, phi);
215- ASSERT_TRUE ( psi.ComputeOverlap (psi_0).real () < 1 .-accepted_error_);
217+ ASSERT_TRUE ( std::abs (psi.ComputeOverlap (psi_0).real () - 1 ) < accepted_error_);
218+ ASSERT_TRUE ( std::abs (psi.ComputeOverlap (psi_0).imag () - 0 ) < accepted_error_);
216219 // Special case phi=0 corresponding to a X rotation.
217220 phi = 0 .;
218221 theta = 0.28 ;
219222 qubit = 1 ;
220223 psi.ApplyRotationXY (qubit, phi, theta);
221224 psi.ApplyRotationX (qubit, -theta);
222- ASSERT_TRUE ( psi.ComputeOverlap (psi_0).real () < 1 .-accepted_error_);
225+ ASSERT_TRUE ( std::abs (psi.ComputeOverlap (psi_0).real () - 1 ) < accepted_error_);
226+ ASSERT_TRUE ( std::abs (psi.ComputeOverlap (psi_0).imag () - 0 ) < accepted_error_);
223227 // Special case phi=pi/2 corresponding to a Y rotation.
224228 phi = M_PI/2 ;
225229 qubit = 2 ;
226230 psi.ApplyRotationXY (qubit, phi, theta);
227231 psi.ApplyRotationY (qubit, -theta);
228- ASSERT_TRUE ( psi.ComputeOverlap (psi_0).real () < 1 .-accepted_error_);
232+ ASSERT_TRUE ( std::abs (psi.ComputeOverlap (psi_0).real () - 1 ) < accepted_error_);
233+ ASSERT_TRUE ( std::abs (psi.ComputeOverlap (psi_0).imag () - 0 ) < accepted_error_);
229234}
230235
231236// ////////////////////////////////////////////////////////////////////////////
0 commit comments