Exemplo n.º 1
0
 def test_generate_hex_unif_range(self):
     n = 1000  # (1 - 1/16)^n = 9e-29
     r = set()
     for i in xrange(n):
         r.add(generate_hex_unif(1))
     self.assertEquals(sorted(map(lambda x: str(x).lower(), r)),
                       [c for c in '0123456789abcdef'])
Exemplo n.º 2
0
 def test_generate_hex_unif_range(self):
     n = 1000  # (1 - 1/16)^n = 9e-29
     r = set()
     for i in xrange(n):
         r.add(generate_hex_unif(1))
     self.assertEquals(
         sorted(map(lambda x: str(x).lower(), r)),
         [c for c in '0123456789abcdef']
     )
Exemplo n.º 3
0
 def test_generate_hex_unif_spread(self):
     n = 1000
     m = 32
     # union bound: (1/16)^m * n^2 = 3e-33
     s = set([generate_hex_unif(m) for i in xrange(n)])
     self.assertEquals(len(s), n)
Exemplo n.º 4
0
 def test_generate_hex_unif_len(self):
     h = generate_hex_unif(21)  # (1/16)^(n-1) = 8e-25
     self.assertEquals(len(h), 21)
     self.assertTrue(len(set(c for c in h)) > 1)
Exemplo n.º 5
0
 def test_generate_hex_unif_spread(self):
     n = 1000
     m = 32
     # union bound: (1/16)^m * n^2 = 3e-33
     s = set([generate_hex_unif(m) for i in xrange(n)])
     self.assertEquals(len(s), n)
Exemplo n.º 6
0
 def test_generate_hex_unif_len(self):
     h = generate_hex_unif(21)  # (1/16)^(n-1) = 8e-25
     self.assertEquals(len(h), 21)
     self.assertTrue(len(set(c for c in h)) > 1)