Coverage Report

Created: 2021-08-28 18:14

D:\git\skunkworks\herald-for-cpp\herald-tests\datatypesdataderived-tests.cpp
Line
Count
Source
1
//  Copyright 2020-2021 Herald Project Contributors
2
//  SPDX-License-Identifier: Apache-2.0
3
//
4
5
#include "catch.hpp"
6
7
#include "herald/herald.h"
8
9
10
1
TEST_CASE("datatypes-payloaddata-basics", "[datatypes][payloaddata][basics]") {
11
1
  SECTION("datatypes-payloaddata-basics") {
12
1
    herald::datatype::PayloadData payload{}; // empty default ctor
13
1
14
1
    REQUIRE(payload.size() == 0);
15
1
16
1
    
17
1
    herald::datatype::PayloadData payload2{std::byte('a'), 6}; // repeating byte ctor
18
1
19
1
    REQUIRE(payload2.size() == 6);
20
1
    REQUIRE(payload2.at(0) == std::byte('a'));
21
1
    REQUIRE(payload2.at(5) == std::byte('a'));
22
1
23
1
    const char* charArray = "wotcha";
24
1
    std::byte byteArray[6];
25
7
    for (int i = 0;i < 6;
i++6
) {
26
6
      byteArray[i] = std::byte(charArray[i]);
27
6
    }
28
1
    herald::datatype::PayloadData payload3{byteArray, 4};
29
1
30
1
    REQUIRE(payload3.size() == 4);
31
1
    REQUIRE(payload3.at(0) == std::byte('w'));
32
1
    REQUIRE(payload3.at(3) == std::byte('c'));
33
1
  }
34
1
}
35
36
37
38
1
TEST_CASE("datatypes-immediatesenddata-basics", "[datatypes][immediatesenddata][basics]") {
39
1
  SECTION("datatypes-immediatesenddata-basics") {
40
1
    herald::datatype::Data d{std::byte('f'),8};
41
1
    herald::datatype::ImmediateSendData isd(d);
42
1
43
1
    REQUIRE(isd.size() == 8);
44
1
    REQUIRE(isd.at(0) == std::byte('f'));
45
1
    REQUIRE(isd.at(7) == std::byte('f'));
46
1
  }
47
1
}
48
49
50
1
TEST_CASE("datatypes-payloadsharingdata-basics", "[datatypes][payloadsharingdata][ctor][basics]") {
51
1
  SECTION("datatypes-payloadsharingdata-basics") {
52
1
    herald::datatype::PayloadSharingData psd{{11},{std::byte('g'),4}};
53
1
54
1
    REQUIRE(psd.rssi.intValue() == 11);
55
1
    REQUIRE(psd.data.size() == 4);
56
1
    REQUIRE(psd.data.at(3) == std::byte('g'));
57
1
  }
58
1
}
59