2 * Copyright 2008 Free Software Foundation, Inc.
4 * This file is part of GNU Radio
6 * GNU Radio is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 3, or (at your option)
11 * GNU Radio is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with GNU Radio; see the file COPYING. If not, write to
18 * the Free Software Foundation, Inc., 51 Franklin Street,
19 * Boston, MA 02110-1301, USA.
23 #include <qa_gri_lfsr.h>
24 #include <cppunit/TestAssert.h>
28 qa_gri_lfsr::test_lfsr ()
34 gri_lfsr lfsr1(mask,seed,length);
35 gri_lfsr lfsr2(mask,seed,length);
37 unsigned char expected[] = {1, 0, 1, 1, 0, 1, 0, 1, 0, 0};
39 for(unsigned int i=0; i<31; i++){
43 // test that after one lfsr cycle we still match out uncycled lfsr
44 for (unsigned int i = 0; i < 41; i++) {
45 CPPUNIT_ASSERT_EQUAL((int) lfsr1.next_bit(), (int) lfsr2.next_bit());
48 // test the known correct values at the given shift offset
49 for(unsigned int i=0; i<10; i++){
50 CPPUNIT_ASSERT_EQUAL((int) lfsr1.next_bit(), (int) expected[i]);
53 // test for register length too long
54 CPPUNIT_ASSERT_THROW(gri_lfsr(mask, seed, 32), std::invalid_argument);