コード例 #1
0
 def test_k(self):
     for k in range(100):
         ss = StreamSampler(k)
         for i in range(5 * k):
             ss.append(i)
         self.assertEqual(len(ss), k)
コード例 #2
0
 def test_rand_preserved(self):
     ss = StreamSampler(5)
     for i in range(1000): ss.append(i)
     self.assertEqual(list(ss), sorted(self.ans))
コード例 #3
0
 def test_small(self):
     ss = StreamSampler(5)
     for i in range(5): ss.append(i)
     self.assertEqual(list(ss), list(range(5)))
コード例 #4
0
 def test_rand(self):
     ss = StreamSampler(5, preserve=False)
     for i in range(1000): ss.append(i)
     self.assertEqual(list(ss), self.ans)