1
0
mirror of https://github.com/gnss-sdr/gnss-sdr synced 2024-06-22 21:13:15 +00:00
gnss-sdr/src/tests/unit-tests/system-parameters/glonass_gnav_crc_test.cc
Carles Fernandez 7308745f05
Apply more concise file header format
Re-license CMake scripts with BSD-3-Clause
2020-12-30 13:35:06 +01:00

38 lines
1.5 KiB
C++

/*!
* \file glonass_gnav_crc_test.cc
* \brief Test fot GLONASS GNAV CRC
* \author Carles Fernandez-Prades, 2020. cfernandez(at)cttc.es
*
*
* -----------------------------------------------------------------------------
*
* GNSS-SDR is a Global Navigation Satellite System software-defined receiver.
* This file is part of GNSS-SDR.
*
* Copyright (C) 2020 (see AUTHORS file for a list of contributors)
* SPDX-License-Identifier: GPL-3.0-or-later
*
* -----------------------------------------------------------------------------
*/
#include "glonass_gnav_navigation_message.h"
#include <bitset>
#include <string>
TEST(GlonassCrcTest, GnssSdrCRCTest)
{
// test data
std::string string1Real_14_18_00("0000100000111001001001000011101010101100010101001000001001011101010101110011110110101");
std::string string1Real_14_18_30("0000100000111001001011000011101010101100010101001000001001011101010101110011100001010");
std::string string1Wrong_14_18_00("0000100000111001001001000011101010101100010101001000001001011101010101110011100001010");
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));
}