~aleteoryx/muditaos

ref: sign_test muditaos/module-bluetooth/tests/tests-Devicei.cpp -rw-r--r-- 1.6 KiB
a217eeb3 — Dawid Wojtas [BH-2024] Fix lack of alarm directory after updating software 1 year, 5 months ago
                                                                                
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
// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md

#include <catch2/catch.hpp>
#include "Device.hpp"
#include <btstack_util.h>

Devicei genDev()
{
    Devicei from("from");
    bd_addr_t addr{0, 1, 2, 3, 4, 5};
    from.setAddress(&addr);
    from.pageScanRepetitionMode = 1;
    from.clockOffset            = 1;
    from.classOfDevice          = 1;
    from.state                  = DEVICE_STATE::REMOTE_NAME_REQUEST;
    from.deviceState            = DeviceState::Paired;
    from.isPairingSSP           = true;
    return from;
}

TEST_CASE("Devicei - create copy and move")
{
    Devicei from = genDev();
    Devicei to;

    SECTION("create - by copy")
    {
        SECTION("ctor")
        {
            to = Devicei(from);
        }
        SECTION("operator")
        {
            to.operator=(from);
        }
    }

    SECTION("move")
    {
        // please see that that section depends on previous section working fine
        Devicei base = from;
        SECTION("ctor")
        {
            to = std::move(base);
        }
        SECTION("operator")
        {
            to.operator=(std::move(from));
        }
    }

    REQUIRE(from == to);
    REQUIRE(!(from != to));
    REQUIRE(bd_addr_cmp(from.address, to.address) == 0);
    REQUIRE(from.pageScanRepetitionMode == to.pageScanRepetitionMode);
    REQUIRE(from.clockOffset == to.clockOffset);
    REQUIRE(from.classOfDevice == to.classOfDevice);
    REQUIRE(from.state == to.state);
    REQUIRE(from.deviceState == to.deviceState);
    REQUIRE(from.isPairingSSP == to.isPairingSSP);
}