def test_runtime(self): stack = TripleStack() start = timeit.default_timer() for i in range(1000000): stack.push(i % 3, i % 3) end = timeit.default_timer() print "Running time for pushing %d elements was: %f seconds" % ( i + 1, end - start)
def test_expand(self): stack = TripleStack() for i in range(10): stack.push(i % 3, i % 3) for i in range(20): stack.push(0, 0) print stack
def test_pop_and_peek(self): stack = TripleStack() for i in range(10): stack.push(i % 3, i) for i in range(9, -1, -1): self.assertEquals(stack.pop(i % 3), i) self.assertRaises(KeyError, stack.pop, 0) self.assertEquals(stack.peek(0), None)
def test_all(self): stack = TripleStack() for i in range(50): stack.push(i % 3, i % 3) for i in range(20): stack.pop(i % 3) for i in range(10): stack.push(1, 1) for i in range(5): stack.pop(2) print stack
def test_grow(self): stack = TripleStack() for i in range(10): stack.push(i % 3, i % 3) for i in range(14): stack.push(0, 0) for i in range(7): stack.push(1, 1) print stack
def test_push_and_peek(self): stack = TripleStack() for i in range(10): stack.push(i % 3, i) self.assertEquals(stack.peek(i % 3), i)