def test_bottom_eq(self): """ Test bottom eq constraint """ r1 = BoxStyle() r2 = BoxStyle() r1.min_size = Size(10, 10) r2.min_size = Size(20, 5) r1.size = Size(10, 10) r2.size = Size(20, 5) s = Solver() s.add(MinSize(r1)) s.add(MinSize(r2)) s.add(BottomEq(r1, r2)) s.solve() self.assertTrue(r1.size.width >= 10) self.assertTrue(r1.size.height >= 10) self.assertTrue(r2.size.width >= 20) self.assertTrue(r2.size.height >= 5) self.assertEquals(0, r1.pos.y) self.assertEquals(5, r2.pos.y)
def test_head_size(self): """ Test head size """ style = BoxStyle() style.size = Size(80, 25) style.compartment[0] = 10 self.assertEquals(25, _head_size(style))
def test_head_size_with_one_cmp(self): """ Test head size with one additional compartment """ style = BoxStyle() style.size = Size(80, 55) style.compartment[0] = 10 style.compartment.append(15) self.assertEquals(30, _head_size(style)) # 55 - 5 * 2 (pad) - 15
def test_head_size_with_two_cmp(self): """ Test head size with two additional compartments """ style = BoxStyle() style.size = Size(80, 100) style.compartment[0] = 10 style.compartment.append(15) style.compartment.append(10) self.assertEquals(55, _head_size(style)) # 100 - 5 * 4 (pad) - 25