source: Add class
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 @@
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