From 2cba1c5e0a62950ebc07a0790e0e8994bedf08f0 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Sun, 21 Apr 2019 11:46:33 +0200 Subject: [PATCH] Add test for the serdes_monitor_pvt class --- src/tests/test_main.cc | 1 + .../pvt/serdes_monitor_pvt_test.cc | 47 +++++++++++++++++++ 2 files changed, 48 insertions(+) create mode 100644 src/tests/unit-tests/signal-processing-blocks/pvt/serdes_monitor_pvt_test.cc diff --git a/src/tests/test_main.cc b/src/tests/test_main.cc index 0773a7244..05df98d35 100644 --- a/src/tests/test_main.cc +++ b/src/tests/test_main.cc @@ -120,6 +120,7 @@ DECLARE_string(log_dir); #include "unit-tests/signal-processing-blocks/pvt/rinex_printer_test.cc" #include "unit-tests/signal-processing-blocks/pvt/rtcm_printer_test.cc" #include "unit-tests/signal-processing-blocks/pvt/rtcm_test.cc" +#include "unit-tests/signal-processing-blocks/pvt/serdes_monitor_pvt_test.cc" #include "unit-tests/signal-processing-blocks/telemetry_decoder/galileo_fnav_inav_decoder_test.cc" #include "unit-tests/system-parameters/glonass_gnav_ephemeris_test.cc" #include "unit-tests/system-parameters/glonass_gnav_nav_message_test.cc" diff --git a/src/tests/unit-tests/signal-processing-blocks/pvt/serdes_monitor_pvt_test.cc b/src/tests/unit-tests/signal-processing-blocks/pvt/serdes_monitor_pvt_test.cc new file mode 100644 index 000000000..eb586f147 --- /dev/null +++ b/src/tests/unit-tests/signal-processing-blocks/pvt/serdes_monitor_pvt_test.cc @@ -0,0 +1,47 @@ +/*! + * \file serdes_monitor_pvt_test.cc + * \brief Implements Unit Test for the serdes_monitor_pvt class. + * \author Carles Fernandez_prades, 2019. cfernandez(at)cttc.es + * + * ------------------------------------------------------------------------- + * + * Copyright (C) 2010-2019 (see AUTHORS file for a list of contributors) + * + * GNSS-SDR is a software defined Global Navigation + * Satellite Systems receiver + * + * This file is part of GNSS-SDR. + * + * GNSS-SDR is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * GNSS-SDR is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNSS-SDR. If not, see . + * + * ------------------------------------------------------------------------- + */ + +#include "serdes_monitor_pvt.h" + +TEST(Serdes_Monitor_Pvt_Test, Simpletest) +{ + Monitor_Pvt monitor = Monitor_Pvt(); + double true_latitude = 23.4; + monitor.latitude = true_latitude; + + Serdes_Monitor_Pvt serdes = Serdes_Monitor_Pvt(); + std::string serialized_data = serdes.createProtobuffer(monitor); + + gnss_sdr::MonitorPvt mon; + mon.ParseFromString(serialized_data); + + double read_latitude = mon.latitude(); + EXPECT_NEAR(true_latitude, read_latitude, 0.000001); +}