1
0
mirror of https://github.com/gnss-sdr/gnss-sdr synced 2025-10-20 18:17:42 +00:00

Fixed bug in number of X2 epochs. Added tests

This commit is contained in:
Cillian O'Driscoll
2015-10-31 10:11:38 +00:00
parent 40fffd5837
commit 2b57a7501e
2 changed files with 145 additions and 1 deletions

View File

@@ -163,7 +163,7 @@ const unsigned int GPS_P_Code_Generator::X2A_EPOCHS_PER_X2_EPOCH = 3750;
const unsigned int GPS_P_Code_Generator::X2B_EPOCHS_PER_X2_EPOCH = 3749;
const unsigned int GPS_P_Code_Generator::X1_EPOCHS_PER_WEEK = 403200;
const unsigned int GPS_P_Code_Generator::X2_EPOCHS_PER_WEEK = 403199;
const unsigned int GPS_P_Code_Generator::X2_EPOCHS_PER_WEEK = 403200;
const unsigned int GPS_P_Code_Generator::X1B_EXTRA_LENGTH = 343;
const unsigned int GPS_P_Code_Generator::X2A_EXTRA_LENGTH = 1069;

View File

@@ -31,6 +31,7 @@
#include <gtest/gtest.h>
#include <vector>
#include "GPS_P_CODE.h"
#include "gps_pcode.h"
TEST(PCodeGenTest, X1ATest)
@@ -133,3 +134,146 @@ TEST(PCodeGenTest, FirstChipsTest)
}
TEST(PCodeGenTest, EndX1EpochTest)
{
std::vector< short > dest;
std::vector< short > x1a;
std::vector< short > x1b;
std::vector< short > x2a;
std::vector< short > x2b;
gps_x1a_code_gen( x1a );
gps_x1b_code_gen( x1b );
gps_x2a_code_gen( x2a );
gps_x2b_code_gen( x2b );
GPS_P_Code_Generator pcode_gen;
unsigned int num_chips = 24;
uint64_t end_x1_epoch = 4092LL*3750LL;
uint64_t start_ind = end_x1_epoch - num_chips;
int sv = 1;
pcode_gen.get_chips( sv, start_ind, num_chips, dest );
EXPECT_EQ( dest.size(), num_chips );
for( unsigned ii = 0; ii < num_chips; ++ii )
{
short res = x1a[4092-num_chips+ii]
^ x1b[4092] ^ x2a[4092-num_chips+ii]
^ x2b[4092];
EXPECT_EQ( dest[ii], res );
}
}
TEST(PCodeGenTest, StartSecondX1EpochTest)
{
std::vector< short > dest;
std::vector< short > x1a;
std::vector< short > x1b;
std::vector< short > x2a;
std::vector< short > x2b;
gps_x1a_code_gen( x1a );
gps_x1b_code_gen( x1b );
gps_x2a_code_gen( x2a );
gps_x2b_code_gen( x2b );
GPS_P_Code_Generator pcode_gen;
unsigned int num_chips = 24;
uint64_t end_x1_epoch = 4092LL*3750LL;
uint64_t start_ind = end_x1_epoch;
int sv = 1;
pcode_gen.get_chips( sv, start_ind, num_chips, dest );
EXPECT_EQ( dest.size(), num_chips );
for( unsigned ii = 0; ii < num_chips; ++ii )
{
short res = x1a[ii]
^ x1b[ii] ^ x2a[4091]
^ x2b[4092];
EXPECT_EQ( dest[ii], res );
}
}
TEST(PCodeGenTest, EndOfWeekTest)
{
std::vector< short > dest;
std::vector< short > x1a;
std::vector< short > x1b;
std::vector< short > x2a;
std::vector< short > x2b;
gps_x1a_code_gen( x1a );
gps_x1b_code_gen( x1b );
gps_x2a_code_gen( x2a );
gps_x2b_code_gen( x2b );
GPS_P_Code_Generator pcode_gen;
unsigned int num_chips = 343;
uint64_t end_week = GPS_P_CODE_LENGTH_CHIPS;
uint64_t start_ind = end_week - num_chips;
int sv = 1;
pcode_gen.get_chips( sv, start_ind, num_chips, dest );
EXPECT_EQ( dest.size(), num_chips );
for( unsigned ii = 0; ii < num_chips; ++ii )
{
short res = x1a[4092-num_chips+ii]
^ x1b[4092] ^ x2a[4091]
^ x2b[4092];
EXPECT_EQ( dest[ii], res );
}
}
TEST(PCodeGenTest, Prn37Test)
{
std::vector< short > dest;
std::vector< short > x1a;
std::vector< short > x1b;
std::vector< short > x2a;
std::vector< short > x2b;
gps_x1a_code_gen( x1a );
gps_x1b_code_gen( x1b );
gps_x2a_code_gen( x2a );
gps_x2b_code_gen( x2b );
GPS_P_Code_Generator pcode_gen;
int sv = 37;
unsigned int num_chips = 24+sv-1;
uint64_t start_ind = 0;
pcode_gen.get_chips( sv, start_ind, num_chips, dest );
EXPECT_EQ( dest.size(), num_chips );
for( unsigned ii = sv-1; ii < num_chips; ++ii )
{
short res = x1a[ii]
^ x1b[ii] ^ x2a[ii-sv+1]
^ x2b[ii-sv+1];
EXPECT_EQ( dest[ii], res );
}
}