def test1(self): # simple test with a known answer cont = TopNContainer(4) for foo in range(10): cont.Insert(foo, str(foo)) assert cont.GetPts() == list(range(6, 10)) assert cont.GetExtras() == [str(x) for x in range(6, 10)]
def test_keepAll(self): # simple test with a known answer where we keep all cont = TopNContainer(-1) for i in range(10): cont.Insert(9 - i, str(9 - i)) self.assertEqual(len(cont), i + 1) assert cont.GetPts() == list(range(10)) assert cont.GetExtras() == [str(x) for x in range(10)]
def test3(self): # random test with extras cont = TopNContainer(10) for _ in range(100): v = random.random() cont.Insert(v, v + 1) vs = cont.GetExtras() last = vs.pop(0) while vs: assert vs[0] >= last last = vs.pop(0)