|
| 1 | +#include <boost/ut.hpp> |
| 2 | +#include <gnuradio-4.0/basic/AndConst.hpp> |
| 3 | + |
| 4 | +using namespace gr::basic; |
| 5 | +using namespace boost::ut; |
| 6 | + |
| 7 | +const suite AndConstTests = [] { |
| 8 | + "uint8_t support"_test = [] { |
| 9 | + AndConst<uint8_t> andConstBlock; |
| 10 | + |
| 11 | + // Test default constant = 1 |
| 12 | + andConstBlock.constant = 1; |
| 13 | + expect(eq(andConstBlock.processOne(0xFF), 0x01)); |
| 14 | + expect(eq(andConstBlock.processOne(0x00), 0x00)); |
| 15 | + expect(eq(andConstBlock.processOne(0xAA), 0x00)); |
| 16 | + |
| 17 | + // Test constant = 0 |
| 18 | + andConstBlock.constant = 0; |
| 19 | + expect(eq(andConstBlock.processOne(0xFF), 0x00)); |
| 20 | + expect(eq(andConstBlock.processOne(0x00), 0x00)); |
| 21 | + expect(eq(andConstBlock.processOne(0xAA), 0x00)); |
| 22 | + }; |
| 23 | + |
| 24 | + "int16_t support"_test = [] { |
| 25 | + AndConst<int16_t> andConstBlock; |
| 26 | + |
| 27 | + // Test default constant = 1 |
| 28 | + andConstBlock.constant = 1; |
| 29 | + expect(eq(andConstBlock.processOne(static_cast<int16_t>(0xFF)), 0x0001)); |
| 30 | + expect(eq(andConstBlock.processOne(static_cast<int16_t>(0x00)), 0x0000)); |
| 31 | + expect(eq(andConstBlock.processOne(static_cast<int16_t>(0xAA)), 0x0000)); |
| 32 | + |
| 33 | + // Test constant = 0 |
| 34 | + andConstBlock.constant = 0; |
| 35 | + expect(eq(andConstBlock.processOne(static_cast<int16_t>(0xFF)), 0x0000)); |
| 36 | + expect(eq(andConstBlock.processOne(static_cast<int16_t>(0x00)), 0x0000)); |
| 37 | + expect(eq(andConstBlock.processOne(static_cast<int16_t>(0xAA)), 0x0000)); |
| 38 | + }; |
| 39 | + |
| 40 | + "int32_t support"_test = [] { |
| 41 | + AndConst<int32_t> andConstBlock; |
| 42 | + |
| 43 | + // Test default constant = 1 |
| 44 | + andConstBlock.constant = 1; |
| 45 | + expect(eq(andConstBlock.processOne((0xFF)), 0x00000001)); |
| 46 | + expect(eq(andConstBlock.processOne((0x00)), 0x00000000)); |
| 47 | + expect(eq(andConstBlock.processOne((0xAA)), 0x00000000)); |
| 48 | + |
| 49 | + // Test constant = 0 |
| 50 | + andConstBlock.constant = 0; |
| 51 | + expect(eq(andConstBlock.processOne((0xFF)), 0x00000000)); |
| 52 | + expect(eq(andConstBlock.processOne((0x00)), 0x00000000)); |
| 53 | + expect(eq(andConstBlock.processOne((0xAA)), 0x00000000)); |
| 54 | + }; |
| 55 | +}; |
| 56 | + |
| 57 | +int main() { return boost::ut::cfg<boost::ut::override>.run(); } |
0 commit comments