2014-03-23 09:45:03 +00:00
|
|
|
/*!
|
|
|
|
* \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
|
|
|
* -----------------------------------------------------------------------------
|
2014-03-23 09:45:03 +00:00
|
|
|
*
|
2020-12-30 12:35:06 +00:00
|
|
|
* GNSS-SDR is a Global Navigation Satellite System software-defined receiver.
|
2014-03-23 09:45:03 +00:00
|
|
|
* This file is part of GNSS-SDR.
|
|
|
|
*
|
2020-12-30 12:35:06 +00:00
|
|
|
* Copyright (C) 2010-2020 (see AUTHORS file for a list of contributors)
|
2020-02-08 00:20:02 +00:00
|
|
|
* SPDX-License-Identifier: GPL-3.0-or-later
|
2014-03-23 09:45:03 +00:00
|
|
|
*
|
2020-07-28 14:57:15 +00:00
|
|
|
* -----------------------------------------------------------------------------
|
2014-03-23 09:45:03 +00:00
|
|
|
*/
|
|
|
|
|
2018-02-25 21:49:06 +00:00
|
|
|
|
2020-06-18 09:49:28 +00:00
|
|
|
#include "gnss_sdr_make_unique.h"
|
2014-03-23 09:45:03 +00:00
|
|
|
#include "rtcm_printer.h"
|
2018-12-09 21:00:09 +00:00
|
|
|
#include <string>
|
2014-03-23 09:45:03 +00:00
|
|
|
|
|
|
|
|
2017-06-25 20:53:11 +00:00
|
|
|
TEST(RtcmPrinterTest, Instantiate)
|
2014-03-23 09:45:03 +00:00
|
|
|
{
|
|
|
|
std::string filename = "hello.rtcm";
|
|
|
|
bool flag_rtcm_tty_port = false;
|
|
|
|
std::string rtcm_dump_devname = "/dev/pts/4";
|
2015-12-24 19:56:41 +00:00
|
|
|
bool flag_rtcm_server = false;
|
2018-10-27 22:42:28 +00:00
|
|
|
bool rtcm_file_output_enabled = false;
|
2016-05-06 19:00:08 +00:00
|
|
|
unsigned short rtcm_tcp_port = 2101;
|
|
|
|
unsigned short rtcm_station_id = 1234;
|
2020-06-18 09:49:28 +00:00
|
|
|
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);
|
2014-03-23 09:45:03 +00:00
|
|
|
}
|
|
|
|
|
2016-04-30 13:20:56 +00:00
|
|
|
|
2017-06-25 20:53:11 +00:00
|
|
|
TEST(RtcmPrinterTest, Run)
|
2014-03-23 09:45:03 +00:00
|
|
|
{
|
2015-11-22 13:43:52 +00:00
|
|
|
std::string filename = "test.rtcm";
|
2014-03-23 09:45:03 +00:00
|
|
|
bool flag_rtcm_tty_port = false;
|
2018-10-27 22:42:28 +00:00
|
|
|
bool rtcm_file_output_enabled = false;
|
2014-03-23 09:45:03 +00:00
|
|
|
std::string rtcm_dump_devname = "/dev/pts/4";
|
2015-12-24 19:56:41 +00:00
|
|
|
bool flag_rtcm_server = false;
|
2016-05-06 19:00:08 +00:00
|
|
|
unsigned short rtcm_tcp_port = 2101;
|
|
|
|
unsigned short rtcm_station_id = 1234;
|
2014-03-23 09:45:03 +00:00
|
|
|
|
2020-06-18 09:49:28 +00:00
|
|
|
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);
|
2015-11-22 13:43:52 +00:00
|
|
|
|
2014-03-23 09:45:03 +00:00
|
|
|
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];
|
2018-03-03 01:03:39 +00:00
|
|
|
for (unsigned int i = 0; i < reference_msg.length(); i = i + 2)
|
2016-04-30 13:20:56 +00:00
|
|
|
{
|
2018-08-10 19:16:10 +00:00
|
|
|
uint64_t n, n2;
|
2018-03-03 01:03:39 +00:00
|
|
|
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;
|
2018-03-03 01:03:39 +00:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2015-11-23 23:31:53 +00:00
|
|
|
std::string testing_msg = RTCM_printer->print_MT1005_test();
|
2014-03-23 09:45:03 +00:00
|
|
|
|
2016-04-30 13:20:56 +00:00
|
|
|
EXPECT_EQ(0, reference_msg_binary.compare(testing_msg));
|
2014-03-23 09:45:03 +00:00
|
|
|
}
|