Example #1
0
    def test_add_and_get_line2(self):
        line = SparseLine()

        line.add_value(100, 100)
        line.add_value(100, 100)
        line.add_value(110, 100)
        print(line.get_line(99, 111))

        r = line.get_line(99, 111)
        self.assertEqual(r[0], 0)  # 99
        self.assertEqual(r[1], 200)  # 100
        self.assertEqual(r[2], 100)  # 101

        self.assertEqual(len(r), 3)
Example #2
0
    def test_add_value(self):
        line = SparseLine()
        line.add_value(1, 100)
        line.add_value(1, 100)
        line.add_value(1, 100)
        print(line.get_value(1))
        self.assertEqual(line.get_value(1), 300)

        line.add_value(2, 100)
        self.assertEqual(line.get_value(1), 300)
        print(line.get_value(1))
        self.assertEqual(line.get_value(2), 100)
        print(line.get_value(2))