Ejemplo n.º 1
0
    def test_choice(self):
        blah = chc.Choice('blah', [fld.Field('a', 8), fld.Field('b', 8)])
        stream = chsr._ProtocolStream(blah)
        self.assertEqual(0, len(stream.data))

        # Now we should move to 'a' or 'b'
        next = stream.next()
        self.assertEqual(2, len(next))
        self.assertEqual('a', next[0].entry.name)

        # Now both options should finish
        self.assertEqual(0, len(next[0].next()))
        self.assertEqual(0, len(next[1].next()))
Ejemplo n.º 2
0
    def test_sequence(self):
        blah = seq.Sequence('blah', [fld.Field('a', 8), fld.Field('b', 8)])
        stream = chsr._ProtocolStream(blah)
        self.assertEqual(0, len(stream.data))

        # Now we should move to 'a'
        next = stream.next()
        self.assertEqual(1, len(next))
        self.assertEqual('a', next[0].entry.name)

        # Now we should move to 'b'
        next = next[0].next()
        self.assertEqual(1, len(next))
        self.assertEqual('b', next[0].entry.name)

        # And then we should be done.
        self.assertEqual(0, len(next[0].next()))
Ejemplo n.º 3
0
 def test_field(self):
     a = fld.Field('a', 8)
     stream = chsr._ProtocolStream(a)
     self.assertEqual(a, stream.entry)
     self.assertEqual([], stream.next())