def testToBERBooleanKnownValues(self): """str(BERBoolean(n)) should give known result with known input""" for integer, encoded, dummy in self.knownValues: result = pureber.BERBoolean(integer) result = str(result) result = list(map(ord, result)) self.assertEqual(encoded, result)
def testToBERBooleanKnownValues(self): """BERBoolean(n).toWire() should give known result with known input""" for integer, encoded, dummy in self.knownValues: result = pureber.BERBoolean(integer) result = result.toWire() result = l(result) self.assertEqual(encoded, result)
def testPartialBERBooleanEncodings(self): """BERBoolean(encoded="...") with too short input should throw BERExceptionInsufficientData""" m=str(pureber.BERBoolean(42)) assert len(m)==3 self.assertRaises(pureber.BERExceptionInsufficientData, pureber.berDecodeObject, pureber.BERDecoderContext(), m[:2]) self.assertRaises(pureber.BERExceptionInsufficientData, pureber.berDecodeObject, pureber.BERDecoderContext(), m[:1]) self.assertEquals((None, 0), pureber.berDecodeObject(pureber.BERDecoderContext(), ''))
def testPartialBERBooleanEncodings(self): """BERBoolean(encoded="...") with too short input should throw BERExceptionInsufficientData""" m = pureber.BERBoolean(42).toWire() self.assertEqual(3, len(m)) self.assertRaises( pureber.BERExceptionInsufficientData, pureber.berDecodeObject, pureber.BERDecoderContext(), m[:2], ) self.assertRaises( pureber.BERExceptionInsufficientData, pureber.berDecodeObject, pureber.BERDecoderContext(), m[:1], ) self.assertEqual((None, 0), pureber.berDecodeObject(pureber.BERDecoderContext(), ""))