summaryrefslogtreecommitdiffstats
path: root/test/internal/utils.cpp
diff options
context:
space:
mode:
authorWilliam A. Kennington III <wak@google.com>2019-03-29 15:36:39 -0700
committerWilliam A. Kennington III <wak@google.com>2019-03-29 15:45:51 -0700
commit8eaf5fcc598df14c8956c5afe657f51e683074ef (patch)
tree339cbd4f5bf2433c573f99de687670066a9f3099 /test/internal/utils.cpp
parent2584f9d7b91e2d14ddc9bdcb45fc5133a083b522 (diff)
downloadsdeventplus-8eaf5fcc598df14c8956c5afe657f51e683074ef.tar.gz
sdeventplus-8eaf5fcc598df14c8956c5afe657f51e683074ef.zip
internal/utils: performCallback should preserve argument references
Arguments including the function are now passed with reference types forwarded. Change-Id: I32cf4704737faa6c140d16352528ceb0d738f5b8 Signed-off-by: William A. Kennington III <wak@google.com>
Diffstat (limited to 'test/internal/utils.cpp')
-rw-r--r--test/internal/utils.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/test/internal/utils.cpp b/test/internal/utils.cpp
index 403964c..8f5d75c 100644
--- a/test/internal/utils.cpp
+++ b/test/internal/utils.cpp
@@ -1,7 +1,10 @@
+#include <functional>
#include <gtest/gtest.h>
+#include <memory>
#include <sdeventplus/internal/utils.hpp>
#include <stdexcept>
#include <system_error>
+#include <utility>
namespace sdeventplus
{
@@ -15,6 +18,20 @@ TEST(UtilsTest, PerformCallbackSuccess)
EXPECT_EQ(0, performCallback(nullptr, []() {}));
}
+TEST(UtilsTest, PerformCallbackAcceptsReference)
+{
+ auto f =
+ std::bind([](const std::unique_ptr<int>&) {}, std::make_unique<int>(1));
+ EXPECT_EQ(0, performCallback(nullptr, f));
+}
+
+TEST(UtilsTest, PerformCallbackAcceptsMove)
+{
+ auto f =
+ std::bind([](const std::unique_ptr<int>&) {}, std::make_unique<int>(1));
+ EXPECT_EQ(0, performCallback(nullptr, std::move(f)));
+}
+
TEST(UtilsTest, SetPrepareSystemError)
{
EXPECT_EQ(-EBUSY, performCallback("system_error", []() {
OpenPOWER on IntegriCloud