From 0cf4a5e168e0ab9b9d6ecdb176e25548c67bea7f Mon Sep 17 00:00:00 2001 From: Robin Kuzmin Date: Thu, 4 Feb 2021 18:37:09 -0800 Subject: [PATCH] Restructured the files. --- src/QirRuntime/test/QIR-static/CMakeLists.txt | 3 ++- src/QirRuntime/test/QIR-static/qir-driver.cpp | 17 ----------------- .../test/QIR-static/qir-test-math.cpp | 16 ++++++++++++++++ 3 files changed, 18 insertions(+), 18 deletions(-) create mode 100644 src/QirRuntime/test/QIR-static/qir-test-math.cpp diff --git a/src/QirRuntime/test/QIR-static/CMakeLists.txt b/src/QirRuntime/test/QIR-static/CMakeLists.txt index 7a7e99eb1fb..84f18e774c0 100644 --- a/src/QirRuntime/test/QIR-static/CMakeLists.txt +++ b/src/QirRuntime/test/QIR-static/CMakeLists.txt @@ -20,7 +20,8 @@ add_custom_target(qir_static_test_lib DEPENDS ${QIR_TESTS_LIBS}) # The executable target for QIR tests triggers the custom actions to compile ll files # add_executable(qir-static-tests - qir-driver.cpp) + qir-driver.cpp + qir-test-math.cpp) target_link_libraries(qir-static-tests PUBLIC ${QIR_TESTS_LIBS} diff --git a/src/QirRuntime/test/QIR-static/qir-driver.cpp b/src/QirRuntime/test/QIR-static/qir-driver.cpp index 9f8e4398c92..bac6bc26414 100644 --- a/src/QirRuntime/test/QIR-static/qir-driver.cpp +++ b/src/QirRuntime/test/QIR-static/qir-driver.cpp @@ -7,7 +7,6 @@ #include #include #include -#include #include "CoreTypes.hpp" #include "QuantumApi_I.hpp" @@ -320,19 +319,3 @@ TEST_CASE("QIR: application of nested controlled functor", "[qir]") g_ctrqapi = nullptr; } - - - - -extern "C" double __quantum__qis__sqrt__body(double); // NOLINT - -TEST_CASE("QIR: math", "[qir.math][qir.math.sqrt]") -{ - REQUIRE(2.0 == __quantum__qis__sqrt__body((double)4.0)); - REQUIRE(3.0 == __quantum__qis__sqrt__body((double)9.0)); - REQUIRE(10.0 == __quantum__qis__sqrt__body((double)100.0)); - - REQUIRE( isnan(__quantum__qis__sqrt__body((double)-5.0)) ); // (double)NAN == sqrt((double)-5.0) - REQUIRE( isnan(__quantum__qis__sqrt__body(nan(""))) ); // (double)NAN == sqrt((double)) - REQUIRE( isinf(__quantum__qis__sqrt__body((double)INFINITY)) ); // +-infinity == sqrt((double) +infinity) -} diff --git a/src/QirRuntime/test/QIR-static/qir-test-math.cpp b/src/QirRuntime/test/QIR-static/qir-test-math.cpp new file mode 100644 index 00000000000..929c6cfded8 --- /dev/null +++ b/src/QirRuntime/test/QIR-static/qir-test-math.cpp @@ -0,0 +1,16 @@ +#include + +#include "catch.hpp" + +extern "C" double __quantum__qis__sqrt__body(double); // NOLINT + +TEST_CASE("QIR: math.sqrt", "[qir.math][qir.math.sqrt]") +{ + REQUIRE(2.0 == __quantum__qis__sqrt__body((double)4.0)); + REQUIRE(3.0 == __quantum__qis__sqrt__body((double)9.0)); + REQUIRE(10.0 == __quantum__qis__sqrt__body((double)100.0)); + + REQUIRE( isnan(__quantum__qis__sqrt__body((double)-5.0)) ); // (double)NAN == sqrt((double)-5.0) + REQUIRE( isnan(__quantum__qis__sqrt__body(nan(""))) ); // (double)NAN == sqrt((double)) + REQUIRE( isinf(__quantum__qis__sqrt__body((double)INFINITY)) ); // +-infinity == sqrt((double) +infinity) +}