Coverage Report

Created: 2026-04-12 06:23

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/opendnp3/cpp/tests/dnp3mocks/src/MockLowerLayer.cpp
Line
Count
Source
1
/*
2
 * Copyright 2013-2022 Step Function I/O, LLC
3
 *
4
 * Licensed to Green Energy Corp (www.greenenergycorp.com) and Step Function I/O
5
 * LLC (https://stepfunc.io) under one or more contributor license agreements.
6
 * See the NOTICE file distributed with this work for additional information
7
 * regarding copyright ownership. Green Energy Corp and Step Function I/O LLC license
8
 * this file to you under the Apache License, Version 2.0 (the "License"); you
9
 * may not use this file except in compliance with the License. You may obtain
10
 * a copy of the License at:
11
 *
12
 * http://www.apache.org/licenses/LICENSE-2.0
13
 *
14
 * Unless required by applicable law or agreed to in writing, software
15
 * distributed under the License is distributed on an "AS IS" BASIS,
16
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17
 * See the License for the specific language governing permissions and
18
 * limitations under the License.
19
 */
20
#include "dnp3mocks/MockLowerLayer.h"
21
22
#include <ser4cpp/util/HexConversions.h>
23
24
#include <cassert>
25
26
using namespace opendnp3;
27
using namespace ser4cpp;
28
29
bool MockLowerLayer::HasNoData() const
30
0
{
31
0
    return sendQueue.empty();
32
0
}
33
34
size_t MockLowerLayer::NumWrites() const
35
0
{
36
0
    return sendQueue.size();
37
0
}
38
39
std::string MockLowerLayer::PopWriteAsHex()
40
0
{
41
0
    if (sendQueue.empty())
42
0
    {
43
0
        return "";
44
0
    }
45
46
0
    auto ret = sendQueue.front();
47
0
    sendQueue.pop();
48
0
    return HexConversions::to_hex(ret.payload);
49
0
}
50
51
bool MockLowerLayer::BeginTransmit(const Message& message)
52
5.98k
{
53
5.98k
    this->sendQueue.push(message);
54
5.98k
    return true;
55
5.98k
}
56
57
void MockLowerLayer::SendUp(const rseq_t& data, const Addresses& addresses)
58
0
{
59
0
    if (pUpperLayer)
60
0
    {
61
0
        pUpperLayer->OnReceive(Message(addresses, data));
62
0
    }
63
0
}
64
65
void MockLowerLayer::SendUp(const std::string& arHexData, const Addresses& addresses)
66
0
{
67
0
    const auto buffer = HexConversions::from_hex(arHexData);
68
0
    this->SendUp(buffer->as_rslice(), addresses);
69
0
}
70
71
void MockLowerLayer::SendComplete()
72
0
{
73
0
    if (pUpperLayer)
74
0
    {
75
0
        pUpperLayer->OnTxReady();
76
0
    }
77
0
}
78
79
void MockLowerLayer::ThisLayerUp()
80
0
{
81
0
    if (pUpperLayer)
82
0
    {
83
0
        pUpperLayer->OnLowerLayerUp();
84
0
    }
85
0
}
86
void MockLowerLayer::ThisLayerDown()
87
0
{
88
0
    if (pUpperLayer)
89
0
    {
90
0
        pUpperLayer->OnLowerLayerDown();
91
0
    }
92
0
}