def test_short_string_segfaults(self): a = cbson.dumps({"A": [1, 2, 3, 4, 5, "6", u"7", {"C": u"DS"}]}) for i in range(len(a))[1:]: try: cbson.loads(a[:-i] + (" " * i)) except Exception: pass
def test_known_bad(self): for s in KNOWN_BAD: try: d = base64.b64decode(s) cbson.loads(d) except cbson.BSONError: pass
def test_random_segfaults(self): a = cbson.dumps({"A": [1, 2, 3, 4, 5, "6", u"7", {"C": u"DS"}]}) sys.stdout.write("\nQ: %s\n" % (binascii.hexlify(a),)) for _ in range(1000): l = [c for c in a] l[random.randint(4, len(a)-1)] = chr(random.randint(0, 255)) try: s = "".join(l) sys.stdout.write("s: %s\n" % (binascii.hexlify(s),)) sys.stdout.flush() cbson.loads(s) except Exception as e: sys.stdout.write(" ERROR: %r\n" % (e,)) sys.stdout.flush()
def test_random_segfaults(self): a = cbson.dumps({"A": [1, 2, 3, 4, 5, "6", u"7", {"C": u"DS"}]}) sys.stdout.write("\nQ: %s\n" % (binascii.hexlify(a), )) for _ in range(1000): l = [c for c in a] l[random.randint(4, len(a) - 1)] = chr(random.randint(0, 255)) try: s = "".join(l) sys.stdout.write("s: %s\n" % (binascii.hexlify(s), )) sys.stdout.flush() cbson.loads(s) except Exception as e: sys.stdout.write(" ERROR: %r\n" % (e, )) sys.stdout.flush()
def cbson_decode_empty(): cbson.loads(EMPTY_BSON)
def cbson_decode_with_id(): cbson.loads(DOC_WITH_ID)
def cbson_decode_datetime_bson(): cbson.loads(DATETIME_BSON)
def cbson_decode_25x_level(): cbson.loads(_25X_BSON)