You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
srsRAN_4G/lib/test/common/bcd_helpers_test.cc

54 lines
1.0 KiB
C++

/**
*
* \section COPYRIGHT
*
* Copyright 2013-2020 Software Radio Systems Limited
*
* By using this file, you agree to the terms and conditions set
* forth in the LICENSE file which can be found at the top level of
* the distribution.
*
*/
#include "srslte/common/bcd_helpers.h"
#include <assert.h>
using namespace srslte;
int main(int argc, char** argv)
{
std::string mcc_str = "001";
std::string mnc_str = "001";
uint16_t mcc;
uint16_t mnc;
// String to code
assert(string_to_mcc(mcc_str, &mcc));
assert(mcc == 0xF001);
assert(string_to_mnc(mnc_str, &mnc));
assert(mnc == 0xF001);
mnc_str = "01";
assert(string_to_mnc(mnc_str, &mnc));
assert(mnc == 0xFF01);
// Code to string
mcc_str = "";
mnc_str = "";
mcc = 0xF001;
mnc = 0xF001;
assert(mcc_to_string(mcc, &mcc_str));
assert(mcc_str.compare("001") == 0);
assert(mnc_to_string(mnc, &mnc_str));
assert(mnc_str.compare("001") == 0);
mnc = 0xFF01;
assert(mnc_to_string(mnc, &mnc_str));
assert(mnc_str.compare("01") == 0);
}