mirror of
https://github.com/Show-maket/IR-protocol.git
synced 2026-09-21 20:39:35 +00:00
archive: freeze IR-protocol WIP before stepwise integration
This commit is contained in:
69
tests/test_protocol_contract.cpp
Normal file
69
tests/test_protocol_contract.cpp
Normal file
@ -0,0 +1,69 @@
|
||||
#include "IR_DecoderRaw.h"
|
||||
|
||||
#include <cassert>
|
||||
#include <cstdint>
|
||||
#include <iostream>
|
||||
|
||||
namespace {
|
||||
|
||||
// Reproduces the removed 2025 expression exactly, but with integer arithmetic:
|
||||
// 2.7735 == 27735 / 10000. It is a provenance golden, not a new PHY rule.
|
||||
constexpr uint32_t removedLegacyResponseExpressionMs()
|
||||
{
|
||||
const uint64_t scaledUs =
|
||||
static_cast<uint64_t>(irproto::kNominalRxInterEdgeTimeoutUs) * 27735U / 10000U;
|
||||
return static_cast<uint16_t>(scaledUs) / 1000U;
|
||||
}
|
||||
|
||||
static_assert(irproto::kWireFrameLengthBits == 5U, "wire length field changed");
|
||||
static_assert(irproto::kWireFrameLengthMask == 31U, "wire length mask changed");
|
||||
static_assert(irproto::kMaxWireFrameBytes == 31U, "wire frame limit changed");
|
||||
static_assert(irproto::kDataFrameOverheadBytes == 7U, "DATA overhead changed");
|
||||
static_assert(irproto::kBackFrameOverheadBytes == 5U, "BACK overhead changed");
|
||||
static_assert(irproto::kBackToFrameOverheadBytes == 7U, "BACK_TO overhead changed");
|
||||
static_assert(irproto::kMaxDataPayloadBytes == 24U, "DATA payload limit changed");
|
||||
static_assert(irproto::kMaxBackPayloadBytes == 26U, "BACK payload limit changed");
|
||||
static_assert(irproto::kMaxBackToPayloadBytes == 24U, "BACK_TO payload limit changed");
|
||||
static_assert(irproto::kMaxLogicalGateRuns == 688U, "logical max-frame run bound changed");
|
||||
static_assert(irproto::maxPhysicalGateRunCapacity(UINT8_MAX) == 738U,
|
||||
"uint8 carrier-multiply storage bound changed");
|
||||
|
||||
static_assert(IR_MASK_MSG_TYPE == irproto::kMessageTypeMask, "legacy type mask diverged");
|
||||
static_assert(IR_MASK_MSG_INFO == irproto::kWireFrameLengthMask, "legacy length mask diverged");
|
||||
static_assert(bytePerPack == irproto::kMaxWireFrameBytes,
|
||||
"legacy bytePerPack value must remain source-compatible");
|
||||
static_assert(dataByteSizeMax == irproto::kMaxWireFrameBytes,
|
||||
"legacy storage alias must follow the wire limit");
|
||||
|
||||
static_assert(irproto::kRxInterEdgeTimeoutBitWindows == 12U,
|
||||
"8 data + 3 sync + 1 guard geometry changed");
|
||||
static_assert(irproto::kNominalRxInterEdgeTimeoutUs == 15144U,
|
||||
"nominal inter-edge timeout changed");
|
||||
static_assert(irproto::kNominalRxSilenceTimeoutUs == 30288U,
|
||||
"nominal RX silence timeout changed");
|
||||
static_assert(irproto::microsToMillisCeil(irproto::kNominalRxSilenceTimeoutUs) == 31U,
|
||||
"RX silence ceil-ms conversion changed");
|
||||
static_assert(IR_ResponseDelay == 42U, "deployed response turn-around changed");
|
||||
static_assert(removedLegacyResponseExpressionMs() == IR_ResponseDelay,
|
||||
"named empirical response delay no longer matches its legacy provenance");
|
||||
|
||||
void testAdaptiveTimingGeometry()
|
||||
{
|
||||
assert(irproto::rxInterEdgeTimeoutUs(700U) == 12000U);
|
||||
assert(irproto::rxSilenceTimeoutUs(700U) == 24000U);
|
||||
assert(irproto::rxInterEdgeTimeoutUs(1000U) == 15600U);
|
||||
assert(irproto::rxSilenceTimeoutUs(1000U) == 31200U);
|
||||
assert(irproto::microsToMillisCeil(0U) == 0U);
|
||||
assert(irproto::microsToMillisCeil(1U) == 1U);
|
||||
assert(irproto::microsToMillisCeil(1000U) == 1U);
|
||||
assert(irproto::microsToMillisCeil(1001U) == 2U);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
int main()
|
||||
{
|
||||
testAdaptiveTimingGeometry();
|
||||
std::cout << "IR protocol geometry contract tests: OK\n";
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user