diff --git a/orc-rt/unittests/BootstrapInfoTest.cpp b/orc-rt/unittests/BootstrapInfoTest.cpp index 67f497a49c8e..2a87597ca6e4 100644 --- a/orc-rt/unittests/BootstrapInfoTest.cpp +++ b/orc-rt/unittests/BootstrapInfoTest.cpp @@ -15,22 +15,10 @@ #include "orc-rt/TaskDispatcher.h" #include "gtest/gtest.h" +#include "CommonTestUtils.h" + using namespace orc_rt; -static ExecutorProcessInfo mockExecutorProcessInfo() noexcept { - return ExecutorProcessInfo("arm64-apple-darwin", 16384); -} - -class NoDispatcher : public TaskDispatcher { -public: - void dispatch(std::unique_ptr T) override { - assert(false && "strictly no dispatching!"); - } - void shutdown() override {} -}; - -static void noErrors(Error Err) { cantFail(std::move(Err)); } - TEST(BootstrapInfoTest, ExplicitConstruction) { Session S(mockExecutorProcessInfo(), std::make_unique(), noErrors); diff --git a/orc-rt/unittests/CommonTestUtils.h b/orc-rt/unittests/CommonTestUtils.h index d5a6c644537e..e0ec3442f743 100644 --- a/orc-rt/unittests/CommonTestUtils.h +++ b/orc-rt/unittests/CommonTestUtils.h @@ -9,11 +9,28 @@ #ifndef ORC_RT_UNITTEST_COMMONTESTUTILS_H #define ORC_RT_UNITTEST_COMMONTESTUTILS_H +#include "orc-rt/Error.h" +#include "orc-rt/ExecutorProcessInfo.h" +#include "orc-rt/TaskDispatcher.h" #include "orc-rt/move_only_function.h" #include #include +inline void noErrors(orc_rt::Error Err) { orc_rt::cantFail(std::move(Err)); } + +inline orc_rt::ExecutorProcessInfo mockExecutorProcessInfo() noexcept { + return orc_rt::ExecutorProcessInfo("arm64-apple-darwin", 16384); +} + +class NoDispatcher : public orc_rt::TaskDispatcher { +public: + void dispatch(std::unique_ptr T) override { + assert(false && "strictly no dispatching!"); + } + void shutdown() override {} +}; + template class OpCounter { public: OpCounter() { ++DefaultConstructions; } diff --git a/orc-rt/unittests/SessionTest.cpp b/orc-rt/unittests/SessionTest.cpp index 5c10d9b4707d..ce0c77c9af76 100644 --- a/orc-rt/unittests/SessionTest.cpp +++ b/orc-rt/unittests/SessionTest.cpp @@ -17,6 +17,8 @@ #include "gmock/gmock.h" #include "gtest/gtest.h" +#include "CommonTestUtils.h" + #include #include #include @@ -68,18 +70,6 @@ public: void doMoreConfig(int) noexcept {} }; -static ExecutorProcessInfo mockExecutorProcessInfo() noexcept { - return ExecutorProcessInfo("arm64-apple-darwin", 16384); -} - -class NoDispatcher : public TaskDispatcher { -public: - void dispatch(std::unique_ptr T) override { - assert(false && "strictly no dispatching!"); - } - void shutdown() override {} -}; - class EnqueueingDispatcher : public TaskDispatcher { public: using OnShutdownRunFn = move_only_function; @@ -273,10 +263,6 @@ private: orc_rt_WrapperFunction Fn; }; -// Non-overloaded version of cantFail: allows easy construction of -// move_only_functionss. -static void noErrors(Error Err) { cantFail(std::move(Err)); } - TEST(SessionTest, TrivialConstructionAndDestruction) { Session S(mockExecutorProcessInfo(), std::make_unique(), noErrors);