File: catch2_w_attribute_set_write_value.cpp

package info (click to toggle)
tango 10.0.2%2Bdfsg1-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 89,936 kB
  • sloc: cpp: 201,786; sh: 1,645; python: 953; java: 800; perl: 467; javascript: 447; xml: 325; makefile: 272; sql: 72; ruby: 24
file content (65 lines) | stat: -rw-r--r-- 2,032 bytes parent folder | download | duplicates (3)
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
57
58
59
60
61
62
63
64
65
#include "catch2_common.h"

#include <vector>

SCENARIO("Call set_write_value with a std::string")
{
    GIVEN("A scalar w_attribute of type string")
    {
        std::vector<Tango::AttrProperty> properties;
        Tango::Attr attribute("test", Tango::DEV_STRING, Tango::READ_WRITE);
        Tango::WAttribute attr(properties, attribute, "test/test/test", 0);

        THEN("The setpoint is not initialized")
        {
            Tango::DevString res;
            REQUIRE_NOTHROW(attr.get_write_value(res));

            using Catch::Matchers::Equals;
            REQUIRE_THAT(res, Equals("Not initialised"));
        }
        WHEN("Calling set_write_value with a vector of string")
        {
            std::vector<std::string> values;
            values.push_back("val_1");
            REQUIRE_NOTHROW(attr.set_write_value(values));
            THEN("the setpoint is properly set")
            {
                Tango::DevString res;
                REQUIRE_NOTHROW(attr.get_write_value(res));

                using Catch::Matchers::Equals;
                REQUIRE_THAT(res, Equals("val_1"));
            }
        }
    }
}

SCENARIO("Call set_write_value with a bool")
{
    GIVEN("A scalar w_attribute of type bool")
    {
        std::vector<Tango::AttrProperty> properties;
        Tango::Attr attribute("test", Tango::DEV_BOOLEAN, Tango::READ_WRITE);
        Tango::WAttribute attr(properties, attribute, "test/test/test", 0);

        THEN("The setpoint is not initialized")
        {
            bool res;
            REQUIRE_NOTHROW(attr.get_write_value(res));
            REQUIRE(res);
        }
        WHEN("Calling set_write_value with a vector of bool")
        {
            std::vector<bool> values;
            values.push_back(false);
            REQUIRE_NOTHROW(attr.set_write_value(values));
            THEN("the setpoint is properly set")
            {
                bool res;
                REQUIRE_NOTHROW(attr.get_write_value(res));
                REQUIRE(!res);
            }
        }
    }
}