예제 #1
0
 def t(str, value, remainder):
     print(str)
     # Test "one-shot":
     assert process(str) == (value, remainder)
     # With gibberish added:
     assert process(str + "asdf") == (value, remainder + "asdf")
     # Byte at a time:
     decoder = IncrBDecode()
     for i, c in enumerate(str):
         decoder.add(c)
         retval = decoder.process()
         if retval is not None:
             print(retval)
             assert retval == (value, "")
             assert str[i + 1:] == remainder
             break
예제 #2
0
 def t(str, value, remainder):
     print(str)
     # Test "one-shot":
     assert process(str) == (value, remainder)
     # With gibberish added:
     assert process(str + "asdf") == (value, remainder + "asdf")
     # Byte at a time:
     decoder = IncrBDecode()
     for i, c in enumerate(str):
         decoder.add(c)
         retval = decoder.process()
         if retval is not None:
             print(retval)
             assert retval == (value, "")
             assert str[i + 1:] == remainder
             break
예제 #3
0
 def te(str, exc):
     print(str)
     try:
         process(str)
     except exc:
         pass
     else:
         assert False, "didn't raise exception"
     try:
         decoder = IncrBDecode()
         for c in str:
             decoder.add(c)
             decoder.process()
     except exc:
         pass
     else:
         assert False, "didn't raise exception"
예제 #4
0
 def te(str, exc):
     print(str)
     try:
         process(str)
     except exc:
         pass
     else:
         assert False, "didn't raise exception"
     try:
         decoder = IncrBDecode()
         for c in str:
             decoder.add(c)
             decoder.process()
     except exc:
         pass
     else:
         assert False, "didn't raise exception"
예제 #5
0
def process(input):
    bd = IncrBDecode()
    bd.add(input)
    return bd.process()
예제 #6
0
def process(input):
    bd = IncrBDecode()
    bd.add(input)
    return  bd.process()