| 16 | } // namespace |
| 17 | |
| 18 | int main() |
| 19 | { |
| 20 | using namespace AetherSDR::MemoryFields; |
| 21 | bool ok = true; |
| 22 | |
| 23 | // ── sanitizeText strips NUL and control bytes ─────────────────────────── |
| 24 | { |
| 25 | QString withNul = "FM"; |
| 26 | withNul.insert(1, QChar(QChar::Null)); // "F\0M" |
| 27 | ok &= expect(sanitizeText(withNul) == "FM", |
| 28 | "sanitizeText removes an embedded NUL from a mode value"); |
| 29 | } |
| 30 | ok &= expect(sanitizeText(QString("A\tB\nC\rD")) == "ABCD", |
| 31 | "sanitizeText removes TAB/LF/CR control bytes"); |
| 32 | ok &= expect(sanitizeText(QString("X") + QChar(0x7f) + "Y") == "XY", |
| 33 | "sanitizeText removes the reserved DEL byte"); |
| 34 | ok &= expect(sanitizeText("normal name") == "normal name", |
| 35 | "sanitizeText preserves ordinary printable text incl. spaces"); |
| 36 | |
| 37 | // ── mode helpers ──────────────────────────────────────────────────────── |
| 38 | ok &= expect(isKnownMode("usb"), "isKnownMode is case-insensitive for USB"); |
| 39 | ok &= expect(isKnownMode("NFM"), "isKnownMode accepts NFM"); |
| 40 | ok &= expect(!isKnownMode("FOO"), "isKnownMode rejects an unknown mode"); |
| 41 | ok &= expect(modeToWire(" digu ") == "DIGU", |
| 42 | "modeToWire trims and upper-cases"); |
| 43 | { |
| 44 | QString dirty = "USB"; |
| 45 | dirty.insert(1, QChar(QChar::Null)); |
| 46 | ok &= expect(modeToWire(dirty) == "USB", |
| 47 | "modeToWire also sanitizes control bytes"); |
| 48 | } |
| 49 | |
| 50 | // ── offset direction round-trips ──────────────────────────────────────── |
| 51 | ok &= expect(offsetDirToWire("SIMPLEX") == "simplex", "offsetDirToWire simplex"); |
| 52 | ok &= expect(offsetDirToWire("up") == "up", "offsetDirToWire up"); |
| 53 | ok &= expect(offsetDirToWire("Down") == "down", "offsetDirToWire down"); |
| 54 | ok &= expect(offsetDirToWire("garbage").isEmpty(), |
| 55 | "offsetDirToWire empties an unrecognized direction"); |
| 56 | ok &= expect(offsetDirToDisplay("up") == "UP", "offsetDirToDisplay up"); |
| 57 | ok &= expect(offsetDirToDisplay("") == "SIMPLEX", |
| 58 | "offsetDirToDisplay defaults blank to SIMPLEX"); |
| 59 | |
| 60 | // ── tone mode round-trips ─────────────────────────────────────────────── |
| 61 | ok &= expect(toneModeToWire("CTCSS_TX") == "ctcss_tx", "toneModeToWire ctcss_tx"); |
| 62 | ok &= expect(toneModeToWire("off") == "off", "toneModeToWire off"); |
| 63 | ok &= expect(toneModeToWire("bogus").isEmpty(), |
| 64 | "toneModeToWire empties an unrecognized tone mode"); |
| 65 | ok &= expect(toneModeToDisplay("ctcss_tx") == "CTCSS_TX", "toneModeToDisplay ctcss_tx"); |
| 66 | ok &= expect(toneModeToDisplay("") == "OFF", |
| 67 | "toneModeToDisplay defaults blank to OFF"); |
| 68 | |
| 69 | // ── value lists are populated and well-formed ─────────────────────────── |
| 70 | ok &= expect(modes().contains("USB") && modes().contains("AME"), |
| 71 | "modes() spans the FlexLib demod set"); |
| 72 | ok &= expect(offsetDirectionsDisplay().size() == 3, |
| 73 | "offsetDirectionsDisplay() has SIMPLEX/UP/DOWN"); |
| 74 | ok &= expect(toneModesDisplay() == QStringList({"OFF", "CTCSS_TX"}), |
| 75 | "toneModesDisplay() is OFF then CTCSS_TX"); |
nothing calls this directly
no test coverage detected