def test_duplicate_buffers():
    @run_to_buffer
    def x(data):
        t = data.draw_bytes(10)
        if not any(t):
            data.mark_invalid()
        s = data.draw_bytes(10)
        if s == t:
            data.mark_interesting()
    assert x == bytes_from_list([0] * 9 + [1]) * 2
def test_duplicate_buffers():
    @run_to_buffer
    def x(data):
        t = data.draw_bytes(10)
        if not any(t):
            data.mark_invalid()
        s = data.draw_bytes(10)
        if s == t:
            data.mark_interesting()
    assert x == bytes_from_list([0] * 9 + [1]) * 2
Exemple #3
0
 def draw_float_bytes(random, n):
     assert n == 8
     while True:
         i = random.randint(1, 10)
         if i <= 4:
             f = random.choice(NASTY_FLOATS)
         elif i == 5:
             return bytes_from_list(random.randint(0, 255) for _ in range(8))
         elif i == 6:
             f = random.random() * (random.randint(0, 1) * 2 - 1)
         elif i == 7:
             f = random.gauss(0, 1)
         elif i == 8:
             f = float(random.randint(-2 ** 63, 2 ** 63))
         else:
             f = random.gauss(random.randint(-2 ** 63, 2 ** 63), 1)
         if self.permitted(f):
             return struct.pack(b"!d", f)
Exemple #4
0
 def draw_float_bytes(random, n):
     assert n == 8
     while True:
         i = random.randint(1, 10)
         if i <= 4:
             f = random.choice(NASTY_FLOATS)
         elif i == 5:
             return bytes_from_list(
                 random.randint(0, 255) for _ in range(8))
         elif i == 6:
             f = random.random() * (random.randint(0, 1) * 2 - 1)
         elif i == 7:
             f = random.gauss(0, 1)
         elif i == 8:
             f = float(random.randint(-2**63, 2**63))
         else:
             f = random.gauss(random.randint(-2**63, 2**63), 1)
         if self.permitted(f):
             return struct.pack(b'!d', f)
 def draw_constant(data, n):
     return bytes_from_list([self.random.randint(0, 255)] * n)
Exemple #6
0
 def draw_constant(data, n, distribution):
     return bytes_from_list([
         self.random.randint(0, 255)
     ] * n)