MCPcopy Create free account
hub / github.com/aethersdr/AetherSDR / testBadFcs

Function testBadFcs

tests/hdlc_codec_test.cpp:137–162  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

135}
136
137void testBadFcs()
138{
139 // Corrupt a bit in the middle of the bitstream and verify FCS fails.
140 lm::packet pkt("N0CALL", "APRS", {}, ">Corruption test");
141 auto nrzi = makeNrziBitstream(pkt);
142
143 // Flip a bit roughly in the middle (well away from preamble/postamble flags).
144 size_t mid = nrzi.size() / 2;
145 nrzi[mid] ^= 1;
146
147 HdlcCodec codec;
148 int frames = 0;
149 int badFcs = 0;
150 for (uint8_t bit : nrzi) {
151 if (codec.processBit(bit)) {
152 ++frames;
153 if (!codec.fcsValid())
154 ++badFcs;
155 }
156 }
157
158 // We expect at least one complete frame (may not decode as valid AX.25)
159 // but the FCS should be wrong.
160 report("bad FCS: at least one frame candidate", frames >= 1);
161 report("bad FCS: no valid FCS", badFcs == frames);
162}
163
164void testTwoConsecutiveFrames()
165{

Callers 1

mainFunction · 0.85

Calls 5

makeNrziBitstreamFunction · 0.85
fcsValidMethod · 0.80
reportFunction · 0.70
sizeMethod · 0.45
processBitMethod · 0.45

Tested by

no test coverage detected