def testDiffDequeSum(self): deque = DiffDeque(10) values = [1, 2, 3, 4, 5] stamps = [1, 7, 9, 13, 26] deque.dumps(values, stamps) self.assertTrue(deque.sum(), 5)
def testUniqueDiffDequeSum(self): deque = UniqueDiffDeque(10) values = [2, 2, 3, 5, 5] stamps = [1, 7, 20, 22, 26] deque.dumps(values, stamps) self.assertEqual(deque.sum(), 8)
def testDiffDequeWithNeitherClosedSum(self): deque = DiffDeque(10, closed="neither") values = [1, 2, 3, 4, 5] stamps = [1, 7, 9, 16, 26] deque.dumps(values, stamps) self.assertEqual(deque.sum(), 0)
def testUniqueDiffDequeWithNeitherClosedSum(self): deque = UniqueDiffDeque(10, closed="neither") values = [2, 2, 5, 5, 7] stamps = [1, 16, 20, 22, 26] deque.dumps(values, stamps) self.assertEqual(deque.sum(), 5)
def testUniqueDiffDequeWithLeftClosedSum(self): deque = UniqueDiffDeque(10, closed="left") values = [2, 2, 5, 5, 5] stamps = [1, 16, 20, 22, 26] deque.dumps(values, stamps) self.assertEqual(deque.sum(), 7)
def testDequeSum(self): deque = Deque(5) deque.dumps([1., 2., 3., 4., 5., 6.]) self.assertEqual(deque.sum(), 20.)