summaryrefslogtreecommitdiffstats
path: root/test/source
diff options
context:
space:
mode:
authorWilliam A. Kennington III <wak@google.com>2018-10-29 20:06:45 -0700
committerWilliam A. Kennington III <wak@google.com>2018-10-29 20:43:21 -0700
commitb53ef90218633a1b7c9b0e726a45d86ecb2bfaf0 (patch)
tree19fc58ece366479efa3fa5673de8c9467ade6ac6 /test/source
parent463d5c347819b0d750c1ccaac7aac20c32035df9 (diff)
downloadsdeventplus-b53ef90218633a1b7c9b0e726a45d86ecb2bfaf0.tar.gz
sdeventplus-b53ef90218633a1b7c9b0e726a45d86ecb2bfaf0.zip
source/*: Make updating callbacks possible
Sometimes callers want to be able to update the callback used when the source is acted upon. This is needed for updating references stored in the callback. Tested: Run through the unit test suite. Change-Id: I78bda32569287964bfc9d49501869d3a2b497f3d Signed-off-by: William A. Kennington III <wak@google.com>
Diffstat (limited to 'test/source')
-rw-r--r--test/source/child.cpp4
-rw-r--r--test/source/event.cpp4
-rw-r--r--test/source/io.cpp4
-rw-r--r--test/source/signal.cpp4
-rw-r--r--test/source/time.cpp5
5 files changed, 21 insertions, 0 deletions
diff --git a/test/source/child.cpp b/test/source/child.cpp
index e1e1322..ab173b1 100644
--- a/test/source/child.cpp
+++ b/test/source/child.cpp
@@ -91,6 +91,10 @@ TEST_F(ChildTest, ConstructSuccess)
EXPECT_EQ(1, completions);
EXPECT_EQ(expected_si, return_si);
+ child.set_callback(std::bind([]() {}));
+ EXPECT_EQ(0, handler(nullptr, expected_si, &child));
+ EXPECT_EQ(1, completions);
+
expect_destruct();
}
diff --git a/test/source/event.cpp b/test/source/event.cpp
index 90edaec..e4d7b2a 100644
--- a/test/source/event.cpp
+++ b/test/source/event.cpp
@@ -83,6 +83,10 @@ TEST_F(EventTest, DeferConstruct)
EXPECT_EQ(0, handler(nullptr, &defer));
EXPECT_EQ(1, completions);
+ defer.set_callback(std::bind([]() {}));
+ EXPECT_EQ(0, handler(nullptr, &defer));
+ EXPECT_EQ(1, completions);
+
expect_destruct();
}
diff --git a/test/source/io.cpp b/test/source/io.cpp
index b680be7..89506b1 100644
--- a/test/source/io.cpp
+++ b/test/source/io.cpp
@@ -92,6 +92,10 @@ TEST_F(IOTest, ConstructSuccess)
EXPECT_EQ(5, return_fd);
EXPECT_EQ(EPOLLIN, return_revents);
+ io.set_callback(std::bind([]() {}));
+ EXPECT_EQ(0, handler(nullptr, 5, EPOLLIN, &io));
+ EXPECT_EQ(1, completions);
+
expect_destruct();
}
diff --git a/test/source/signal.cpp b/test/source/signal.cpp
index c99aa6b..d3b53a7 100644
--- a/test/source/signal.cpp
+++ b/test/source/signal.cpp
@@ -92,6 +92,10 @@ TEST_F(SignalTest, ConstructSuccess)
EXPECT_EQ(1, completions);
EXPECT_EQ(expected_si, return_si);
+ signal.set_callback(std::bind([]() {}));
+ EXPECT_EQ(0, handler(nullptr, expected_si, &signal));
+ EXPECT_EQ(1, completions);
+
expect_destruct();
}
diff --git a/test/source/time.cpp b/test/source/time.cpp
index aa25da0..96a920e 100644
--- a/test/source/time.cpp
+++ b/test/source/time.cpp
@@ -90,6 +90,11 @@ TEST_F(TimeTest, ConstructSuccess)
EXPECT_EQ(Time<id>::TimePoint(std::chrono::microseconds(2000100)),
saved_time);
+ time.set_callback(std::bind([]() {}));
+ EXPECT_EQ(0, handler(nullptr, 0, userdata));
+ EXPECT_EQ(Time<id>::TimePoint(std::chrono::microseconds(2000100)),
+ saved_time);
+
expect_time_destroy(expected_event, expected_source);
}
OpenPOWER on IntegriCloud