2020-04-10 11:44:45 +00:00
|
|
|
/*!
|
|
|
|
* \file glonass_gnav_crc_test.cc
|
|
|
|
* \brief Test fot GLONASS GNAV CRC
|
|
|
|
* \author Carles Fernandez-Prades, 2020. cfernandez(at)cttc.es
|
|
|
|
*
|
|
|
|
*
|
2020-07-28 14:57:15 +00:00
|
|
|
* -----------------------------------------------------------------------------
|
2020-04-10 11:44:45 +00:00
|
|
|
*
|
2020-12-30 12:35:06 +00:00
|
|
|
* GNSS-SDR is a Global Navigation Satellite System software-defined receiver.
|
2020-04-10 11:44:45 +00:00
|
|
|
* This file is part of GNSS-SDR.
|
|
|
|
*
|
2020-12-30 12:35:06 +00:00
|
|
|
* Copyright (C) 2020 (see AUTHORS file for a list of contributors)
|
2020-04-10 11:44:45 +00:00
|
|
|
* SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
*
|
2020-07-28 14:57:15 +00:00
|
|
|
* -----------------------------------------------------------------------------
|
2020-04-10 11:44:45 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "glonass_gnav_navigation_message.h"
|
|
|
|
#include <bitset>
|
2022-08-26 13:27:01 +00:00
|
|
|
#include <iostream>
|
2020-04-10 11:44:45 +00:00
|
|
|
|
|
|
|
TEST(GlonassCrcTest, GnssSdrCRCTest)
|
|
|
|
{
|
|
|
|
// test data
|
|
|
|
std::string string1Real_14_18_00("0000100000111001001001000011101010101100010101001000001001011101010101110011110110101");
|
|
|
|
std::string string1Real_14_18_30("0000100000111001001011000011101010101100010101001000001001011101010101110011100001010");
|
2022-08-26 13:27:01 +00:00
|
|
|
std::string string1Wrong_14_18_00("0000100000111001001001100011101010101100010101001000001001011101010101110011100001010");
|
2020-04-10 11:44:45 +00:00
|
|
|
|
|
|
|
auto gnav_msg = Glonass_Gnav_Navigation_Message();
|
|
|
|
std::bitset<GLONASS_GNAV_STRING_BITS> bits;
|
|
|
|
bits = std::bitset<GLONASS_GNAV_STRING_BITS>(string1Real_14_18_00);
|
|
|
|
ASSERT_TRUE(gnav_msg.CRC_test(bits));
|
|
|
|
bits = std::bitset<GLONASS_GNAV_STRING_BITS>(string1Real_14_18_30);
|
|
|
|
ASSERT_TRUE(gnav_msg.CRC_test(bits));
|
|
|
|
bits = std::bitset<GLONASS_GNAV_STRING_BITS>(string1Wrong_14_18_00);
|
|
|
|
ASSERT_FALSE(gnav_msg.CRC_test(bits));
|
2022-08-26 13:27:01 +00:00
|
|
|
bits = std::bitset<GLONASS_GNAV_STRING_BITS>(string1Real_14_18_30);
|
|
|
|
for (int k = 8; k < 85; k++)
|
|
|
|
{
|
|
|
|
std::bitset<GLONASS_GNAV_STRING_BITS> corrupt_bits = bits;
|
|
|
|
corrupt_bits[k] = corrupt_bits[k] ? false : true;
|
|
|
|
ASSERT_TRUE(gnav_msg.CRC_test(corrupt_bits));
|
|
|
|
ASSERT_TRUE(corrupt_bits == bits);
|
|
|
|
}
|
2020-04-10 11:44:45 +00:00
|
|
|
}
|