Minor source reorganization; few dangerous C functions replaced with safer std:: alternatives

This commit is contained in:
Pavel Kirienko
2014-02-01 19:00:05 +04:00
parent b385ffb12e
commit 00b977eb40
9 changed files with 43 additions and 40 deletions
@@ -4,6 +4,7 @@
#include <gtest/gtest.h>
#include "common.hpp"
#include <uavcan/can_driver.hpp>
TEST(CanFrame, FrameProperties)
{
@@ -1,10 +1,12 @@
/*
* Copyright (C) 2014 Pavel Kirienko <pavel.kirienko@gmail.com>
* Copyright (C) 2014 <pavel.kirienko@gmail.com>
*/
#pragma once
#include <uavcan/internal/can_io.hpp>
#include <cassert>
#include <uavcan/can_driver.hpp>
#include <uavcan/system_clock.hpp>
class SystemClockMock : public uavcan::ISystemClock
{
@@ -47,32 +49,3 @@ static uavcan::CanFrame makeFrame(uint32_t id, const std::string& str_data, Fram
id |= (type == EXT) ? uavcan::CanFrame::FLAG_EFF : 0;
return uavcan::CanFrame(id, reinterpret_cast<const uint8_t*>(str_data.c_str()), str_data.length());
}
namespace
{
int getQueueLength(uavcan::CanTxQueue& queue)
{
const uavcan::CanTxQueue::Entry* p = queue.peek();
int length = 0;
while (p)
{
length++;
p = p->getNextListNode();
}
return length;
}
bool isInQueue(uavcan::CanTxQueue& queue, const uavcan::CanFrame& frame)
{
const uavcan::CanTxQueue::Entry* p = queue.peek();
while (p)
{
if (frame == p->frame)
return true;
p = p->getNextListNode();
}
return false;
}
}
@@ -5,7 +5,9 @@
#include <queue>
#include <vector>
#include <gtest/gtest.h>
#include "common.hpp"
#include <uavcan/internal/transport/can_io.hpp>
#include "../../common.hpp"
class CanIfaceMock : public uavcan::ICanIface
{
@@ -3,7 +3,33 @@
*/
#include <gtest/gtest.h>
#include "common.hpp"
#include <uavcan/internal/transport/can_io.hpp>
#include "../../common.hpp"
static int getQueueLength(uavcan::CanTxQueue& queue)
{
const uavcan::CanTxQueue::Entry* p = queue.peek();
int length = 0;
while (p)
{
length++;
p = p->getNextListNode();
}
return length;
}
static bool isInQueue(uavcan::CanTxQueue& queue, const uavcan::CanFrame& frame)
{
const uavcan::CanTxQueue::Entry* p = queue.peek();
while (p)
{
if (frame == p->frame)
return true;
p = p->getNextListNode();
}
return false;
}
TEST(CanTxQueue, Qos)
{