Пример #1
0
    def test_find_intersection_x6_l1_1(self):
        li1 = LayoutIndex(1)
        li2 = LayoutIndex(1)
        r = SolveMethod.find_intersection([li1, li2],
                                          [-1, li1, -1, -1, li2, -1], 1)

        self.assertEqual(r, [0, li1, 0, 0, li2, 0])
Пример #2
0
 def test_get_offset_from_start_5(self):
     # index, layout, line
     li1 = LayoutIndex(3)
     li2 = LayoutIndex(2)
     r = SolveMethod.get_offset_from_start(li1, [-1, -1, -1, -1, li2, li2],
                                           True)
     self.assertEqual(r, 0)
Пример #3
0
    def test_fill_full_line_9(self):
        li1 = LayoutIndex(1)
        li2 = LayoutIndex(1)
        r = SolveMethod.fill_line([li1, li2],
                                  [-1, -1, -1, -1, li1, -1, -1, li2, -1], 1)

        self.assertEqual(r, [(li1, None), (li1, None), (li1, None),
                             (li1, None), li1, (li1, li2), (li1, li2), li2,
                             (li2, None)])
Пример #4
0
    def test_find_intersection_v2_x13_l2_1_1_2(self):
        li1 = LayoutIndex(2)
        li2 = LayoutIndex(1)
        li3 = LayoutIndex(1)
        li4 = LayoutIndex(2)
        r = SolveMethod.find_intersection(
            [li1, li2, li3, li4],
            [-1, -1, -1, li1, 0, li2, 0, li3, 0, li4, -1, -1, -1], 1)

        self.assertEqual(r,
                         [0, 0, li1, li1, 0, li2, 0, li2, 0, li4, li4, 0, 0])
Пример #5
0
    def test_find_intersection_x13_l1_7_1(self):
        li1 = LayoutIndex(1)
        li2 = LayoutIndex(7)
        li3 = LayoutIndex(1)
        r = SolveMethod.find_intersection(
            [li1, li2, li3],
            [-1, -1, -1, -1, li2, li2, li2, li2, li2, -1, -1, -1, -1], 1)

        self.assertEqual(r, [
            None, None, None, None, li2, li2, li2, li2, li2, None, None, None,
            None
        ])
Пример #6
0
 def test_get_offset_from_end_4(self):
     li1 = LayoutIndex(3)
     (offset,
      layout) = SolveMethod.get_offset_from_end([li1],
                                                [-1, -1, li1, -1, -1, -1],
                                                1)
     self.assertEqual(offset, 5)
Пример #7
0
    def test_get_suitable_line_up_7(self):
        li1 = LayoutIndex(2)
        r = SolveMethod.get_suitable_line_up(li1, [-1, li1, -1, -1, -1, -1], 1)

        self.assertEqual(len(r), 2)
        self.assertEqual(r[0], [li1, li1, -1, -1, -1, -1])
        self.assertEqual(r[1], [-1, li1, li1, -1, -1, -1])
Пример #8
0
    def test_fill_full_line_7(self):
        li1 = LayoutIndex(4)
        r = SolveMethod.fill_line([li1], [-1, -1, -1, -1, -1, -1, -1, li1, -1],
                                  1)

        self.assertEqual(r, [(li1, None), (li1, None), (li1, None),
                             (li1, None), li1, li1, li1, li1, None])
Пример #9
0
 def test_min_layout_size_3(self):
     li1 = LayoutIndex(3)
     li2 = LayoutIndex(6)
     r = SolveMethod.layout_min_size([li1, li2], 0)
     self.assertEqual(r, 9)
Пример #10
0
    def test_find_intersection_x10_l4(self):
        li1 = LayoutIndex(4)
        r = SolveMethod.find_intersection(
            [li1], [-1, li1, li1, li1, -1, -1, -1, -1, -1, -1], 1)

        self.assertEqual(r, [None, li1, li1, li1, None, 0, 0, 0, 0, 0])
Пример #11
0
    def test_find_intersection_x5_l2(self):
        li1 = LayoutIndex(2)
        r = SolveMethod.find_intersection([li1], [-1] * 5, 1)

        self.assertEqual(r, [None] * 5)
Пример #12
0
    def test_find_intersection_x5_l3_already_full(self):
        li1 = LayoutIndex(3)
        r = SolveMethod.find_intersection([li1], [-1, li1, li1, li1, -1], 1)

        self.assertEqual(r, [0, li1, li1, li1, 0])
Пример #13
0
 def test_get_offset_from_start_3(self):
     # index, layout, line
     li1 = LayoutIndex(3)
     r = SolveMethod.get_offset_from_start(li1, [-1, -1, -1, li1, li1, li1],
                                           False)
     self.assertEqual(r, 3)
Пример #14
0
    def test_fill_when_input_line_is_empty(self):
        li1 = LayoutIndex(1)
        li2 = LayoutIndex(2)
        r = SolveMethod.fill_line([li1, li2], [-1, -1, -1, -1, -1, -1], 1)

        self.assertEqual(r, [li1, (li1, li2), li2, li2, None, None])
Пример #15
0
 def test_min_layout_size_4(self):
     li1 = LayoutIndex(3)
     li2 = LayoutIndex(6)
     li3 = LayoutIndex(13)
     r = SolveMethod.layout_min_size([li1, li2, li3], 1)
     self.assertEqual(r, 24)
Пример #16
0
 def test_merge_lineups_1(self):
     li1 = LayoutIndex(2)
     r = SolveMethod.merge_lineups([[li1, li1, -1, -1, -1],
                                    [-1, li1, li1, -1, -1]])
     self.assertEqual(r, [None, li1, None, -1, -1])
Пример #17
0
 def test_get_suitable_line_up_5(self):
     li1 = LayoutIndex(3)
     self.assertRaises(LineOutOfRange, SolveMethod.get_suitable_line_up,
                       li1, [-1, -1], 1)
Пример #18
0
 def test_min_layout_size_1(self):
     li1 = LayoutIndex(3)
     r = SolveMethod.layout_min_size([li1], 1)
     self.assertEqual(r, 3)
Пример #19
0
    def test_fill_full_line_1(self):
        li1 = LayoutIndex(2)
        li2 = LayoutIndex(1)
        r = SolveMethod.fill_line([li1, li2], [-1, -1, -1, -1], 1)

        self.assertEqual(r, [li1, li1, (li1, li2), li2])
Пример #20
0
    def test_fill_when_layout_need_more_than_nessasary(self):
        li1 = LayoutIndex(2)
        li2 = LayoutIndex(3)

        self.assertRaises(LineOutOfRange, SolveMethod.fill_line, [li1, li2],
                          [-1, -1, -1, -1, -1], 1)
Пример #21
0
 def test_get_offset_from_end_6(self):
     li1 = LayoutIndex(2)
     li2 = LayoutIndex(1)
     (offset, layout) = SolveMethod.get_offset_from_end(
         [li1, li2], [-1, -1, -1, li1, li1, -1, li2, -1], 1)
     self.assertEqual(offset, 6)
Пример #22
0
    def test_find_intersection_x4_l2_with_dot(self):
        li1 = LayoutIndex(2)
        r = SolveMethod.find_intersection([li1], [-1, -1, 0, -1], 1)

        self.assertEqual(r, [li1, li1, 0, 0])
Пример #23
0
 def test_get_minimum_offset_3(self):
     li1 = LayoutIndex(1)
     offset = SolveMethod.get_minimum_offset(li1, [-1, li1, -1, -1, -1], 1)
     self.assertEqual(offset, 3)
Пример #24
0
    def test_find_intersection_x4_l2a1(self):
        li1 = LayoutIndex(2)
        li2 = LayoutIndex(1)
        r = SolveMethod.find_intersection([li1, li2], [-1, -1, -1, -1], 1)

        self.assertEqual(r, [li1, li1, 0, li2])
Пример #25
0
    def test_get_suitable_line_up_3(self):
        li1 = LayoutIndex(4)
        r = SolveMethod.get_suitable_line_up(li1, [-1, -1, 0, -1], 1)

        self.assertEqual(r, [])
Пример #26
0
 def test_get_offset_from_start_4(self):
     li1 = LayoutIndex(2)
     li2 = LayoutIndex(4)
     self.assertRaises(IndexOutOfRange, SolveMethod.get_offset_from_start,
                       li1, [-1, li2, li2, li2, li2, -1], False)
Пример #27
0
    def test_find_intersection_x5_l3(self):
        li1 = LayoutIndex(3)
        r = SolveMethod.find_intersection([li1], [-1, -1, -1, -1, -1], 1)

        self.assertEqual(r, [None, None, li1, None, None])
Пример #28
0
    def __getIndex(self, value):
        self._uid = self._uid + 1
        index = LayoutIndex(value)
        self._idToIndex[index.id()] = index

        return index