File: MessageFixtureBase.h

package info (click to toggle)
odil 0.12.0-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, sid
  • size: 5,092 kB
  • sloc: cpp: 54,080; python: 3,896; xml: 182; makefile: 94
file content (56 lines) | stat: -rw-r--r-- 2,110 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#ifndef _779c46d6_b6ea_443a_9642_f1ec5b87d4b3
#define _779c46d6_b6ea_443a_9642_f1ec5b87d4b3

#include "odil/DataSet.h"
#include "odil/Exception.h"
#include "odil/message/Message.h"

/// @brief Base class for fixtures of Message-derived classes.
template<typename TMessage>
struct MessageFixtureBase
{
    /// @brief Check that a specific message can be constructed from a generic Message.
    void check_message_constructor(std::shared_ptr<odil::DataSet> command_set)
    {
        auto generic_message = std::make_shared<odil::message::Message const>(command_set);
        TMessage const message(generic_message);
        this->check(message);
    }

    /// @brief Check that a specific message can be constructed from a generic Message.
    void check_message_constructor(
        std::shared_ptr<odil::DataSet> command_set,
        std::shared_ptr<odil::DataSet> data_set)
    {
        auto generic_message = std::make_shared<odil::message::Message>(
            command_set, data_set);
        TMessage const message(generic_message);
        this->check(message);
    }

    /// @brief Check that a specific message cannot be constructed from a generic Message.
    void check_message_constructor_throw(
        std::shared_ptr<odil::DataSet> command_set)
    {
        auto const generic_message =
            std::make_shared<odil::message::Message>(command_set);
        BOOST_CHECK_THROW(
            TMessage const message(generic_message), odil::Exception);
    }

    /// @brief Check that a specific message cannot be constructed from a generic Message.
    void check_message_constructor_throw(
        std::shared_ptr<odil::DataSet> command_set,
        std::shared_ptr<odil::DataSet> data_set)
    {
    auto const generic_message =
        std::make_shared<odil::message::Message>(command_set, data_set);
        BOOST_CHECK_THROW(
            TMessage const message(generic_message), odil::Exception);
    }

    /// @brief Check that the specific message attributes are set correctly
    virtual void check(TMessage const & message) =0;
};

#endif // _779c46d6_b6ea_443a_9642_f1ec5b87d4b3