| 163 | } |
| 164 | |
| 165 | void testInterElementGapIsOneUnit() |
| 166 | { |
| 167 | Recorder rec; |
| 168 | IambicKeyer k; |
| 169 | k.setOnKeyDownChange([&](bool d) { rec.onKeyDownChange(d); }); |
| 170 | k.setOnPaddleEvent([&](bool d, bool h) { rec.onPaddleEvent(d, h); }); |
| 171 | k.setWpm(kTestWpm); |
| 172 | k.setMode(IambicKeyer::Mode::IambicB); |
| 173 | k.start(); |
| 174 | |
| 175 | k.setPaddleState(true, true); |
| 176 | std::this_thread::sleep_for(500ms); |
| 177 | k.setPaddleState(false, false); |
| 178 | std::this_thread::sleep_for(200ms); |
| 179 | k.stop(); |
| 180 | |
| 181 | const auto evs = rec.events(); |
| 182 | bool ok = (evs.size() >= 4); |
| 183 | if (ok) { |
| 184 | // Gap = (on→off→on) where the off→on transition is the gap. |
| 185 | // Index 1 is first key-up, index 2 is next key-down. |
| 186 | ok &= nearMs(evs[2].at - evs[1].at, kTestUnitMs); |
| 187 | } |
| 188 | report("inter-element gap is 1 unit (~60ms at 20 WPM)", ok); |
| 189 | } |
| 190 | |
| 191 | void testReleaseStopsAfterCurrentElement() |
| 192 | { |
no test coverage detected