package com.sptmobile.endpoint import org.junit.Assert.assertEquals import org.junit.Assert.assertNull import org.junit.Test /** Parity twin of `rust/link-proto/src/event.rs` tests. */ class EventFrameTest { @Test fun ampLastDecodeOrder() { // `&lt;` must decode to the literal text `<`, NOT to `<`. assertEquals("<", EventFrame.decodeBody("&lt;")) assertEquals( "a\nb \"q\" & done", EventFrame.decodeBody("a
b <x> "q" & done"), ) } @Test fun eventRoundTripWithJsonAttr() { // The composed user-msg envelope: json attr rides attr-escaped and // must come back verbatim — the msg-id dedup seam (KNOWN-HAZARDS 3.1). val frame = """hello
world
""" val ev = EventFrame.parse(frame)!! assertEquals("user-msg", ev.attr("type")) assertEquals("mobile-gw", ev.attr("from")) assertEquals("""{"origin":"voice","msg-id":"u-1"}""", ev.attr("json")) assertEquals("hello\nworld", ev.body) } @Test fun malformedFramesAreNullNotFatal() { assertNull(EventFrame.parse("body")) } }