1
0
mirror of https://github.com/gnss-sdr/gnss-sdr synced 2024-12-15 12:40:35 +00:00
gnss-sdr/tests/unit-tests/signal-processing-blocks/pvt/rtcm_printer_test.cc

67 lines
2.4 KiB
C++
Raw Normal View History

/*!
* \file rtcm_printer_test.cc
* \brief Implements Unit Test for the Rtcm_Printer class.
* \author Carles Fernandez-Prades, 2013. cfernandez(at)cttc.es
*
2020-07-28 14:57:15 +00:00
* -----------------------------------------------------------------------------
*
* GNSS-SDR is a Global Navigation Satellite System software-defined receiver.
* This file is part of GNSS-SDR.
*
* Copyright (C) 2010-2020 (see AUTHORS file for a list of contributors)
* SPDX-License-Identifier: GPL-3.0-or-later
*
2020-07-28 14:57:15 +00:00
* -----------------------------------------------------------------------------
*/
#include "gnss_sdr_make_unique.h"
#include "rtcm_printer.h"
#include <string>
TEST(RtcmPrinterTest, Instantiate)
{
std::string filename = "hello.rtcm";
bool flag_rtcm_tty_port = false;
std::string rtcm_dump_devname = "/dev/pts/4";
bool flag_rtcm_server = false;
bool rtcm_file_output_enabled = false;
unsigned short rtcm_tcp_port = 2101;
unsigned short rtcm_station_id = 1234;
auto RTCM_printer = std::make_unique<Rtcm_Printer>(filename, rtcm_file_output_enabled, flag_rtcm_server, flag_rtcm_tty_port, rtcm_tcp_port, rtcm_station_id, rtcm_dump_devname);
}
2016-04-30 13:20:56 +00:00
TEST(RtcmPrinterTest, Run)
{
std::string filename = "test.rtcm";
bool flag_rtcm_tty_port = false;
bool rtcm_file_output_enabled = false;
std::string rtcm_dump_devname = "/dev/pts/4";
bool flag_rtcm_server = false;
unsigned short rtcm_tcp_port = 2101;
unsigned short rtcm_station_id = 1234;
auto RTCM_printer = std::make_unique<Rtcm_Printer>(filename, rtcm_file_output_enabled, flag_rtcm_server, flag_rtcm_tty_port, rtcm_tcp_port, rtcm_station_id, rtcm_dump_devname);
std::string reference_msg = "D300133ED7D30202980EDEEF34B4BD62AC0941986F33360B98";
2016-04-30 13:20:56 +00:00
/* Convert the reference message to binary data */
std::string reference_msg_binary;
unsigned char c[1];
for (unsigned int i = 0; i < reference_msg.length(); i = i + 2)
2016-04-30 13:20:56 +00:00
{
uint64_t n, n2;
std::istringstream(reference_msg.substr(i, 1)) >> std::hex >> n;
2016-05-01 23:24:23 +00:00
std::istringstream(reference_msg.substr(i + 1, 1)) >> std::hex >> n2;
c[0] = static_cast<unsigned char>(n * 16) + static_cast<unsigned char>(n2);
std::string ret(c, c + 1);
2016-04-30 13:20:56 +00:00
reference_msg_binary += ret;
}
std::string testing_msg = RTCM_printer->print_MT1005_test();
2016-04-30 13:20:56 +00:00
EXPECT_EQ(0, reference_msg_binary.compare(testing_msg));
}