ifw-daq 3.1.0
IFW Data Acquisition modules
Loading...
Searching...
No Matches
testSource.cpp
Go to the documentation of this file.
1/**
2 * @file
3 * @ingroup daq_ocm_libdaq_test
4 * @copyright 2022 ESO - European Southern Observatory
5 *
6 * @brief Test daq::Source and related
7 */
8#include <gtest/gtest.h>
10#include "mock/recifMock.hpp"
11#include <daq/source.hpp>
12
13namespace daq {
14
15/**
16 * Test fixture for source tests.
17 *
18 * @ingroup daq_ocm_libdaq_test
19 */
20class TestSource : public ::testing::Test {
21public:
22 void SetUp() override {
23 m_prim_rr_client = std::make_shared<RecCmdsAsyncMock>();
24 m_meta_rr_client = std::make_shared<MetaDaqAsyncMock>();
25 }
26
27 void TearDown() override {
28 }
29protected:
30 std::shared_ptr<PrimSource::RrClient> m_prim_rr_client;
31 std::shared_ptr<MetaSource::RrClient> m_meta_rr_client;
32};
33
34TEST_F(TestSource, Constructors) {
35 {
36 PrimSource s1("name", m_prim_rr_client);
37 auto s2(s1);
38 auto s3 = s1;
39 auto s4 = std::move(s1);
40 auto s5(std::move(s2));
41 }
42 {
43 MetaSource s1("name", m_meta_rr_client);
44 auto s2(s1);
45 auto s3 = s1;
46 auto s4 = std::move(s1);
47 auto s5(std::move(s2));
48 }
49}
50
51TEST_F(TestSource, Accessors) {
52 {
53 PrimSource s1("name", m_prim_rr_client);
54 EXPECT_EQ(s1.GetName(), "name");
55 EXPECT_EQ(&s1.GetRrClient(), m_prim_rr_client.get());
56 }
57 {
58 MetaSource s1("name", m_meta_rr_client);
59 EXPECT_EQ(s1.GetName(), "name");
60 EXPECT_EQ(&s1.GetRrClient(), m_meta_rr_client.get());
61 }
62}
63
64TEST_F(TestSource, PrimSourceConstructionFailsIfRrClientIsInvalid) {
65 ASSERT_THROW(PrimSource("name", {}), std::invalid_argument);
66}
67
68TEST_F(TestSource, PrimSourceConstructionFailsIfNameIsEmpty) {
69 ASSERT_TRUE(m_prim_rr_client);
70 ASSERT_THROW(PrimSource("", m_prim_rr_client), std::invalid_argument);
71}
72
73TEST_F(TestSource, MetaSourceConstructionFailsIfRrClientIsInvalid) {
74 ASSERT_THROW(MetaSource("name", {}), std::invalid_argument);
75}
76
77TEST_F(TestSource, MetaSourceConstructionFailsIfNameIsEmpty) {
78 ASSERT_TRUE(m_meta_rr_client);
79 ASSERT_THROW(MetaSource("", m_meta_rr_client), std::invalid_argument);
80}
81
82}
Keeps relevant state to be able to communicate with a primary data source.
Definition: source.hpp:142
std::string const & GetName() const
Definition: source.hpp:163
RrClient & GetRrClient()
Definition: source.hpp:167
Keeps relevant state to be able to communicate with a primary data source.
Definition: source.hpp:98
RrClient & GetRrClient()
Definition: source.hpp:123
std::string const & GetName() const
Definition: source.hpp:119
std::shared_ptr< PrimSource::RrClient > m_prim_rr_client
Definition: testSource.cpp:30
void SetUp() override
Definition: testSource.cpp:22
void TearDown() override
Definition: testSource.cpp:27
std::shared_ptr< MetaSource::RrClient > m_meta_rr_client
Definition: testSource.cpp:31
Test fixture for source tests.
Definition: testSource.cpp:20
Mockup of metadaqif classes.
TEST_F(TestDpmClient, StartMonitoringSendsRequestAndReceivesReply)
Mockup of metadaqif classes.
Declarations for daq::Source and related classes.
EXPECT_EQ(meta.rr_uri, "zpb.rr://meta")
ASSERT_TRUE(std::holds_alternative< OlasReceiver >(spec.receivers[0]))