def test_message_type_spec(self) -> None: spec = { 'Test': Specification( Context([]), Package('Test', [ ModularInteger('T', Number(256)), Message('PDU', [ Component('null', '', [Then('Foo', None, Number(1))]), Component('Foo', 'T', [ Then( 'Bar', Number(1), Number(1), And(Equal(Length('Foo'), Number(1)), LessEqual(Value('Foo'), Number(30)))), Then('Baz') ]), Component('Bar', 'T'), Component('Baz', 'T') ]), Message('Simple_PDU', [Component('Bar', 'T'), Component('Baz', 'T')]) ])) } self.assert_specifications([f'{self.testdir}/message_type.rflx'], spec)
def test_enumeration_type_spec(self) -> None: spec = { 'Test': Specification( Context([]), Package('Test', [ Enumeration( 'Day', { 'Mon': Number(1), 'Tue': Number(2), 'Wed': Number(3), 'Thu': Number(4), 'Fri': Number(5), 'Sat': Number(6), 'Sun': Number(7) }, Number(3), False), Enumeration('Gender', { 'M': Number(0), 'F': Number(1) }, Number(1), False), Enumeration('Priority', { 'LOW': Number(1), 'MEDIUM': Number(4), 'HIGH': Number(7) }, Number(3), True) ])) } self.assert_specifications([f'{self.testdir}/enumeration_type.rflx'], spec)
def test_array_type_spec(self) -> None: spec = { 'Test': Specification( Context([]), Package('Test', [ ModularInteger('Byte', Number(256)), Message('Foo', [Component('Byte', 'Byte')]), Array('Bar', 'Foo') ])) } self.assert_specifications([f'{self.testdir}/array_type.rflx'], spec)
def test_integer_type_spec(self) -> None: spec = { 'Test': Specification( Context([]), Package('Test', [ RangeInteger('Page_Num', Number(1), Number(2000), Number(16)), RangeInteger('Line_Size', Number(0), Number(255), Number(8)), ModularInteger('Byte', Number(256)), ModularInteger('Hash_Index', Number(64)) ])) } self.assert_specifications([f'{self.testdir}/integer_type.rflx'], spec)
def test_ethernet_spec(self) -> None: spec = { 'Ethernet': Specification( Context([]), Package('Ethernet', [ RangeInteger('UINT16', Number(0), Sub(Pow(Number(2), Number(16)), Number(1)), Number(16)), ModularInteger('UINT48', Pow(Number(2), Number(48))), Message('Frame', [ Component('Destination', 'UINT48'), Component('Source', 'UINT48'), Component('TPID', 'UINT16', [ Then('TCI', None, None, Equal(Value('TPID'), Number(33024))), Then('EtherType', First('TPID'), None, NotEqual(Value('TPID'), Number(33024))) ]), Component('TCI', 'UINT16'), Component('EtherType', 'UINT16', [ Then('Payload', None, Mul(Value('EtherType'), Number(8)), LessEqual(Value('EtherType'), Number(1500))), Then( 'Payload', None, Sub(Last('Message'), Last('EtherType')), GreaterEqual(Value('EtherType'), Number(1536))) ]), Component('Payload', 'Payload_Array', [ Then( 'null', None, None, And( GreaterEqual( Div(Length('Payload'), Number(8)), Number(46)), LessEqual( Div(Length('Payload'), Number(8)), Number(1500)))) ]) ]) ])) } self.assert_specifications([f'{self.specdir}/ethernet.rflx'], spec)
def test_context_spec(self) -> None: self.assert_specifications([f'{self.testdir}/context.rflx'], { 'Test': Specification(Context(['Foo', 'Bar']), Package('Test', [])) })
def test_package_spec(self) -> None: self.assert_specifications( [f'{self.testdir}/package.rflx'], {'Test': Specification(Context([]), Package('Test', []))})