def test_waste_management(self):
        # Generate one wasted section
        s = skyline.SkylineBlWm(100, 100, rot=False)
        rect1 = s.add_rect(30, 30)
        rect2 = s.add_rect(100, 70)
        self.assertEqual(rect1, Rectangle(0, 0, 30, 30))
        self.assertEqual(rect2, Rectangle(0, 30, 100, 70))
        self.assertEqual(len(s), 2)
        
        # Add rectangle that only fits into wasted section
        self.assertEqual(s.add_rect(71, 30), None)
        self.assertEqual(s.add_rect(70, 31), None) 
        rect3 = s.add_rect(70, 30)
        self.assertEqual(rect3, Rectangle(30, 0, 70, 30))
        self.assertEqual(len(s), 3)
        
        rect4 = s.add_rect(70, 30)
        self.assertEqual(rect4, None)

        # Test the same without waste management
        s = skyline.SkylineBl(100, 100)
        rect1 = s.add_rect(30, 30)
        rect2 = s.add_rect(100, 70)
        self.assertEqual(rect1, Rectangle(0, 0, 30, 30))
        self.assertEqual(rect2, Rectangle(0, 30, 100, 70))
        
        self.assertEqual(s.add_rect(70, 30), None)
        self.assertEqual(len(s), 2)

        # Test waste supports rectangle rotation
        s  = skyline.SkylineBlWm(100, 100, rot=False)
        sr = skyline.SkylineBlWm(100, 100, rot=True)
        self.assertEqual(s.add_rect(30, 30), Rectangle(0, 0, 30, 30))
        self.assertEqual(s.add_rect(100, 70), Rectangle(0, 30, 100, 70))
        self.assertEqual(sr.add_rect(30, 30), Rectangle(0, 0, 30, 30))
        self.assertEqual(sr.add_rect(100, 70), Rectangle(0, 30, 100, 70))
        
        self.assertEqual(s.add_rect(30, 70), None)
        self.assertEqual(sr.add_rect(30, 70), Rectangle(30, 0, 70, 30))
        
        # Try with more than one wasted section
        s = skyline.SkylineBlWm(100, 100, rot=False)
        self.assertEqual(s.add_rect(40, 50), Rectangle(0, 0, 40, 50))
        self.assertEqual(s.add_rect(20, 30), Rectangle(40, 0, 20, 30))
        self.assertEqual(s.add_rect(20, 10), Rectangle(60, 0, 20, 10))
        self.assertEqual(s.add_rect(100, 50), Rectangle(0, 50, 100, 50))

        # Next ones only fit if waste is working
        self.assertEqual(s.add_rect(20, 20), Rectangle(40, 30, 20, 20))
        self.assertEqual(s.add_rect(20, 30), Rectangle(60, 10, 20, 30))
        self.assertEqual(s.add_rect(20, 50), Rectangle(80, 0, 20, 50))
        self.assertEqual(s.add_rect(20, 5), Rectangle(60, 40, 20, 5))
        self.assertEqual(s.add_rect(20, 5), Rectangle(60, 45, 20, 5))
        self.assertEqual(s.add_rect(1, 1), None)
 def test_len(self):
     s = skyline.SkylineBlWm(100, 100)
     self.assertTrue(s.add_rect(50, 50))
     self.assertTrue(s.add_rect(100, 50))
     self.assertEqual(len(s), 2)
     self.assertTrue(s.add_rect(50, 50))
     self.assertEqual(len(s), 3)
  def test_skyline1(self):
      """
      +---------------------------+
      |                           |
      |                           |
      |                           |
      |                           |
      +--------------------+      |
      |                    |      |
      |         4          |      |
      |                    |      |
      |                    |      |
      +----------------+---+------+
      |                |     3    |
      |                |          |
      |       1        +-----+----+
      |                |  2  | w1 |
      |                |     |    |
      +----------------+-----+----+
      """
      s = skyline.SkylineBlWm(100, 100, rot=False)
      rect1 = s.add_rect(50, 40)
      rect2 = s.add_rect(30, 20)
      rect3 = s.add_rect(50, 20)
      rect4 = s.add_rect(70, 30)
      w1 = s.add_rect(20, 20)
 
      self.assertEqual(rect1, Rectangle(0, 0, 50, 40))
      self.assertEqual(rect2, Rectangle(50, 0, 30, 20))
      self.assertEqual(rect3, Rectangle(50, 20, 50, 20))
      self.assertEqual(rect4, Rectangle(0, 40, 70, 30))
      self.assertEqual(w1, Rectangle(80, 0, 20, 20))
 def test_iter(self):
     # Test correctly calculated when waste is enabled
     s = skyline.SkylineBlWm(100, 100)
     self.assertTrue(s.add_rect(50, 50))
     self.assertTrue(s.add_rect(100, 50))
     self.assertEqual(len([r for r in s]), 2)
     self.assertTrue(s.add_rect(40, 40))
     self.assertEqual(len([r for r in s]), 3)
 def test_init(self):
     """Test Waste management is enabled"""
     p = skyline.SkylineBlWm(100, 100)
     self.assertTrue(p._waste_management)