Exemple #1
0
 def test_valid_length_reference() -> None:
     parser = Parser()
     parser.parse_string("""
         package Foo is
             type Element is mod 2**8;
             type Bar is
                 message
                     F1 : Element then F2 with Length => F1;
                     F2 : Payload;
                 end message;
         end Foo;
         """)
Exemple #2
0
 def test_valid_first() -> None:
     parser = Parser()
     parser.parse_string("""
         package Foo is
             type Element is mod 2**8;
             type Bar is
                 message
                     F1 : Element then F2 with First => F1'First;
                     F2 : Element;
                 end message;
         end Foo;
         """)
Exemple #3
0
 def test_valid_use_message_first_last() -> None:
     parser = Parser()
     parser.parse_string("""
         package Foo is
            type Finished is
               message
                  null
                     then Verify_Data
                        with Length => Message'Last - Message'First + 1;
                  Verify_Data : Payload;
               end message;
         end Foo;
         """)
Exemple #4
0
 def test_valid_length_from_message_last() -> None:
     parser = Parser()
     parser.parse_string("""
         package Foo is
             type Element is mod 2**8;
             type Bar is
                 message
                     F1 : Element;
                     F2 : Element
                         then null
                             with Length => Message'Last - F1'Last;
                 end message;
         end Foo;
         """)
Exemple #5
0
 def test_message_with_two_length_fields() -> None:
     parser = Parser()
     parser.parse_string("""
            package Test is
               type Length is mod 2**8;
               type Packet is
                  message
                     Length_1 : Length;
                     Length_2 : Length
                        then Payload
                           with Length => Length_1 + Length_2;
                     Payload : Payload;
                  end message;
            end Test;
         """)
Exemple #6
0
 def test_exclusive_with_length_valid() -> None:
     parser = Parser()
     parser.parse_string("""
         package Foo is
             type Element is range 0..2**32-1 with Size => 32;
             type Bar is
                 message
                     F1 : Element
                         then null
                             if F1'Length = 32 and F1 < 50,
                         then F2
                             if F1'Length = 32 and F1 > 100;
                     F2 : Element;
                 end message;
         end Foo;
         """)
Exemple #7
0
 def test_exclusive_enum_valid() -> None:
     parser = Parser()
     parser.parse_string("""
         package Foo is
             type Kind is (Val1 => 1, Val2 => 2) with Size => 8;
             type Element is range 0..2**32-1 with Size => 32;
             type Bar is
                 message
                     F1 : Kind
                         then null
                             if F1 = Val1,
                         then F2
                             if F1 = Val2;
                     F2 : Element;
                 end message;
         end Foo;
         """)
Exemple #8
0
 def test_tlv_valid_enum() -> None:
     parser = Parser()
     parser.parse_string("""
         package Foo is
             type Tag is (T1, T2, T3) with Size => 8;
             type Length is range 0 .. 2**14 with Size => 16;
             type Bar is
                 message
                     L : Length;
                     T : Tag
                         then V
                             with Length => L
                             if T /= T2 and L <= 2**13;
                     V : Payload;
                 end message;
         end Foo;
         """)
Exemple #9
0
 def assert_refinements_string(self, string: str,
                               refinements: List[Refinement]) -> None:
     parser = Parser()
     parser.parse_string(string)
     self.assertEqual(parser.refinements, refinements)
Exemple #10
0
 def assert_messages_string(self, string: str,
                            messages: List[Message]) -> None:
     parser = Parser()
     parser.parse_string(string)
     self.assert_messages(parser.messages, messages)
Exemple #11
0
 def assert_specifications_string(
         self, string: str, specifications: Dict[str,
                                                 Specification]) -> None:
     parser = Parser()
     parser.parse_string(string)
     self.assertEqual(parser.specifications(), specifications)