Coverage Report

Created: 2021-08-28 18:14

D:\git\skunkworks\herald-for-cpp\herald-tests\fixedpayload-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
#include "test-templates.h"
10
11
1
TEST_CASE("payload-fixed-basic", "[payload][fixed][basic]") {
12
1
  SECTION("payload-fixed-basic") {
13
1
    std::uint16_t country = 826;
14
1
    std::uint16_t state = 4;
15
1
    std::uint64_t clientId = 123456789;
16
1
    herald::payload::fixed::ConcreteFixedPayloadDataSupplierV1 pds(
17
1
      country,
18
1
      state,
19
1
      clientId
20
1
    );
21
1
    BlankDevice bd;
22
1
    auto pd = pds.payload(herald::datatype::PayloadTimestamp(),bd);
23
1
24
1
    REQUIRE(pd.size() == 13); // 1 version code, 2 country, 2 state, 8 clientId = 13
25
1
    std::uint8_t rpidversion = 0;
26
1
    std::uint16_t rc = 0;
27
1
    std::uint16_t rs = 0;
28
1
    std::uint64_t rcid = 0;
29
1
    REQUIRE(pd.uint8(0,rpidversion));
30
1
    REQUIRE(pd.uint16(1,rc));
31
1
    REQUIRE(pd.uint16(3,rs));
32
1
    REQUIRE(pd.uint64(5,rcid));
33
1
    REQUIRE(rpidversion == std::uint8_t(0x08));
34
1
    REQUIRE(rc == country);
35
1
    REQUIRE(rs == state);
36
1
    REQUIRE(rcid == clientId);
37
1
  }
38
1
}