def test_sum_property(self): fifo = FIFORunningSum(3) self.assertEqual(fifo.sum, 0) with self.assertRaises(AttributeError): fifo.sum = 5
def test_len(self): fifo = FIFORunningSum(8) self.assertEqual(len(fifo), 0) fifo.append(1.0) self.assertEqual(len(fifo), 1) self.assertEqual(fifo._buffer.maxlen, 8)
def test_logical_values(self): fifo = FIFORunningSum(3) fifo.append(True) fifo.append(False) fifo.append(True) self.assertEqual(fifo.sum, 2)
def test_fifo_reset(self): fifo = FIFORunningSum(3) fifo.append(1) fifo.append(2) fifo.append(3) fifo.reset() self.assertEqual(fifo.sum, 0) self.assertEqual(fifo._buffer.maxlen, 3) self.assertEqual(len(fifo), 0)
def test_append(self): fifo = FIFORunningSum(3) fifo.append(1) self.assertEqual(fifo.sum, 1) fifo.append(2) self.assertEqual(fifo.sum, 3) fifo.append(3) self.assertEqual(fifo.sum, 6) fifo.append(4) self.assertEqual(fifo.sum, 9) fifo.append(5) self.assertEqual(fifo.sum, 12) fifo.append(6) self.assertEqual(fifo.sum, 15)
def test_max_len(self): tester = FIFORunningSum(8) self.assertEqual(tester.maxlen, 8)
def test_create(self): tester = FIFORunningSum(3) self.assertEqual(tester._buffer.maxlen, 3) self.assertEqual(tester._sum, 0)