| 1 | #ifndef __DEMODULATORDSPTEST_H__ |
|---|
| 2 | #define __DEMODULATORDSPTEST_H__ |
|---|
| 3 | |
|---|
| 4 | #include <cxxtest/TestSuite.h> |
|---|
| 5 | #include "src/DemodulatorDSP.h" |
|---|
| 6 | // |
|---|
| 7 | // A simple test suite: Just inherit CxxTest::TestSuite and write tests! |
|---|
| 8 | // |
|---|
| 9 | |
|---|
| 10 | // NOTE: " : public CxxTest::TestSuite" must be on the same line as the class |
|---|
| 11 | // definition, otherwise the python script does not recognize it |
|---|
| 12 | // as a test class |
|---|
| 13 | class Demodulator_testsuite1 : public CxxTest::TestSuite, |
|---|
| 14 | public DemodulatorDSP |
|---|
| 15 | { |
|---|
| 16 | public: |
|---|
| 17 | |
|---|
| 18 | void test_DemodulateBPSK() { |
|---|
| 19 | short I[7] = {SHRT_MIN, -10000, -1, 0, 1, 10000, SHRT_MAX}; |
|---|
| 20 | short Q[7] = {0, 0, 0, 0, 0, 0, 0}; |
|---|
| 21 | char * bits_out = new char[7]; |
|---|
| 22 | |
|---|
| 23 | SetModulationScheme( MOD_BPSK ); |
|---|
| 24 | DemodulateSequence(I, Q, 7, bits_out); |
|---|
| 25 | |
|---|
| 26 | TS_ASSERT_EQUALS( bits_out[0], BIT0 ); |
|---|
| 27 | TS_ASSERT_EQUALS( bits_out[1], BIT0 ); |
|---|
| 28 | TS_ASSERT_EQUALS( bits_out[2], BIT0 ); |
|---|
| 29 | TS_ASSERT_EQUALS( bits_out[3], BIT0 ); |
|---|
| 30 | TS_ASSERT_EQUALS( bits_out[4], BIT1 ); |
|---|
| 31 | TS_ASSERT_EQUALS( bits_out[5], BIT1 ); |
|---|
| 32 | TS_ASSERT_EQUALS( bits_out[6], BIT1 ); |
|---|
| 33 | |
|---|
| 34 | delete [] bits_out; |
|---|
| 35 | } |
|---|
| 36 | |
|---|
| 37 | void test_DemodulateQPSK() { |
|---|
| 38 | short I[4] = {-10, -10, 10, 10}; |
|---|
| 39 | short Q[4] = {-10, 10, -10, 10}; |
|---|
| 40 | char * bits_out = new char[8]; |
|---|
| 41 | |
|---|
| 42 | SetModulationScheme( MOD_QPSK ); |
|---|
| 43 | DemodulateSequence(I, Q, 4, bits_out); |
|---|
| 44 | |
|---|
| 45 | TS_ASSERT_EQUALS( bits_out[0], BIT0 ); |
|---|
| 46 | TS_ASSERT_EQUALS( bits_out[1], BIT0 ); |
|---|
| 47 | TS_ASSERT_EQUALS( bits_out[2], BIT0 ); |
|---|
| 48 | TS_ASSERT_EQUALS( bits_out[3], BIT1 ); |
|---|
| 49 | TS_ASSERT_EQUALS( bits_out[4], BIT1 ); |
|---|
| 50 | TS_ASSERT_EQUALS( bits_out[5], BIT0 ); |
|---|
| 51 | TS_ASSERT_EQUALS( bits_out[6], BIT1 ); |
|---|
| 52 | TS_ASSERT_EQUALS( bits_out[7], BIT1 ); |
|---|
| 53 | |
|---|
| 54 | delete [] bits_out; |
|---|
| 55 | } |
|---|
| 56 | |
|---|
| 57 | }; |
|---|
| 58 | |
|---|
| 59 | #endif |
|---|
| 60 | |
|---|