def test_deque_size(self): Deq.init() b = cADT.CircleT(pADT.PointT(0,0),10) Deq.pushFront(b) c = cADT.CircleT(pADT.PointT(4,5),3) Deq.pushFront(c) self.assertTrue(Deq.size() == 2)
def test_deque_popFront(self): Deq.init() b = cADT.CircleT(pADT.PointT(0,0),10) Deq.pushFront(b) c = cADT.CircleT(pADT.PointT(4,5),3) Deq.pushFront(c) Deq.popFront() self.assertTrue(Deq.s == [b])
def test_deque_pushFront(self): Deq.init() b = cADT.CircleT(pADT.PointT(0,0),10) for i in range(20): Deq.pushFront(b) self.assertTrue(Deq.s == [b]*20) c = cADT.CircleT(pADT.PointT(4,5),3) with self.assertRaises(FULL): Deq.pushFront(c)
def test_deque_disjoint(self): Deq.init() with self.assertRaises(EMPTY): self.assertTrue(Deq.disjoint()) b = cADT.CircleT(pADT.PointT(0,0),3) Deq.pushFront(b) self.assertTrue(Deq.disjoint()) c = cADT.CircleT(pADT.PointT(14,15),3) Deq.pushFront(c) self.assertTrue(Deq.disjoint()) d = cADT.CircleT(pADT.PointT(30,30),4) Deq.pushFront(d) self.assertTrue(Deq.disjoint())
def test_circle_force(self): q = cADT.CircleT(pADT.PointT(0,0),3) self.assertTrue(q.force(lambda x: x)(cADT.CircleT(pADT.PointT(1.0,0.0),2.0)) == (math.pi*((q.rad())**2.0))*math.pi*2.0**2) self.assertTrue(q.force(lambda x: x*3)(cADT.CircleT(pADT.PointT(0,0),0)) == 0.0)
def test_circle_connection(self): a = cADT.CircleT(pADT.PointT(0,0),5) b = cADT.CircleT(pADT.PointT(9,9),2) d = a.connection(b) self.assertTrue(d.beg().xcrd() == 0 and d.end().xcrd() == 9) self.assertTrue(d.beg().ycrd() == 0 and d.end().ycrd() == 9)
def test_circle_intersect(self): a = cADT.CircleT(pADT.PointT(0,0),5) b = cADT.CircleT(pADT.PointT(9,9),2) self.assertTrue(a.intersect(b) == False)
def test_circle_area(self): a = cADT.CircleT(pADT.PointT(0,0),5) self.assertTrue(a.area() == math.pi*5**2)
def test_circle_rad(self): a = cADT.CircleT(pADT.PointT(0,0),5) self.assertTrue(a.rad() == 5)
def test_circle_cen(self): a = cADT.CircleT(pADT.PointT(0,0),5) self.assertTrue(a.cen().xcrd() == 0 and a.cen().ycrd() == 0)
def test_circle_insideCircle(self): a = cADT.CircleT(pADT.PointT(0,0),10) b = pADT.PointT(9,0) self.assertTrue(cADT.insideCircle(b,a) == True)