diff options
| author | William A. Kennington III <wak@google.com> | 2018-07-17 14:40:14 -0700 |
|---|---|---|
| committer | William A. Kennington III <wak@google.com> | 2018-07-17 14:40:14 -0700 |
| commit | dcc08b6cde29e434a3e7dfd95a6c42fb4bd8484b (patch) | |
| tree | 04cecc3bb4c67fc8dc9d3d6f7953fb84c459e24d /test | |
| parent | 1967df4967e671d4c14410f5b74e89b3f46b23a3 (diff) | |
| download | sdeventplus-dcc08b6cde29e434a3e7dfd95a6c42fb4bd8484b.tar.gz sdeventplus-dcc08b6cde29e434a3e7dfd95a6c42fb4bd8484b.zip | |
source: Add class
Diffstat (limited to 'test')
| -rw-r--r-- | test/Makefile.am | 4 | ||||
| -rw-r--r-- | test/source.cpp | 40 |
2 files changed, 44 insertions, 0 deletions
diff --git a/test/Makefile.am b/test/Makefile.am index 7efd9b2..7534c42 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -24,3 +24,7 @@ exception_LDADD = $(gtest_ldadd) check_PROGRAMS += sdref sdref_SOURCES = sdref.cpp sdref_LDADD = $(gtest_ldadd) + +check_PROGRAMS += source +source_SOURCES = source.cpp +source_LDADD = $(gtest_ldadd) diff --git a/test/source.cpp b/test/source.cpp new file mode 100644 index 0000000..4fa87ab --- /dev/null +++ b/test/source.cpp @@ -0,0 +1,40 @@ +#include <gmock/gmock.h> +#include <gtest/gtest.h> +#include <sdeventplus/source.hpp> +#include <sdeventplus/test/sdevent.hpp> + +namespace sdeventplus +{ +namespace +{ + +using testing::Return; + +class SourceTest : public testing::Test +{ + protected: + testing::StrictMock<SdEventMock> mock; + sd_event_source *const expected_source = + reinterpret_cast<sd_event_source *>(1234); +}; + +TEST_F(SourceTest, NewSourceRef) +{ + EXPECT_CALL(mock, sd_event_source_ref(expected_source)) + .WillOnce(Return(expected_source)); + Source source(expected_source, &mock); + + EXPECT_CALL(mock, sd_event_source_unref(expected_source)) + .WillOnce(Return(nullptr)); +} + +TEST_F(SourceTest, NewSourceNoRef) +{ + Source source(expected_source, std::false_type(), &mock); + + EXPECT_CALL(mock, sd_event_source_unref(expected_source)) + .WillOnce(Return(nullptr)); +} + +} // namespace +} // namespace sdeventplus |

