Beispiel #1
0
def test_findLargest():
    t1 = Triangle(1.2, 2.5)
    t2 = Triangle(1.6, 6.4)
    c1 = Circle(4)
    c2 = Circle(2.2)
    s1 = Square(3.6)

    ss1 = ShapeSet()

    ss1.addShape(t1)
    ss1.addShape(c1)
    ss1.addShape(s1)
    ss1.addShape(t2)
    ss1.addShape(c2)

    t3 = Triangle(3, 8)
    c3 = Circle(1)
    t4 = Triangle(4, 6)

    ss2 = ShapeSet()

    ss2.addShape(t3)
    ss2.addShape(c3)
    ss2.addShape(t4)

    assert findLargest(ss1) == (c1, )
    assert findLargest(ss2) == (t3, t4)
Beispiel #2
0
    def setup(self):
        self.sh = ShapeSet()
        self.sh1 = ShapeSet()
        self.t1 = Triangle(2, 6)
        self.t2 = Triangle(9, 3)
        self.t3 = Square(9)
        self.t4 = Circle(8)

        self.sh.addShape(self.t1)
        self.sh.addShape(self.t2)
        self.sh.addShape(self.t3)
        self.sh1.addShape(self.t1)
        self.l = [self.t1, self.t2, self.t3]
Beispiel #3
0
def test_findLargest():
    ss = ShapeSet()
    t1 = Triangle(3, 8)
    t2 = Triangle(4, 6)
    c1 = Circle(1)

    ss.addShape(t1)
    ss.addShape(t2)
    ss.addShape(c1)

    largest = findLargest(ss)

    for i in largest:
        assert t1 in largest and t2 in largest
Beispiel #4
0
class TestTriangle:
    def setup(self):
        self.t1 = Triangle(12, 12)
        self.t2 = Triangle(10, 12)
        self.t3 = Triangle(12, 13)
        self.t4 = Triangle(10, 12)

    def test_area(self):
        assert self.t1.area() == 72
        assert self.t2.area() == 60
        assert self.t3.area() == 78

    def test_str(self):
        assert str(self.t1) == "Triangle with base 12.0 and height 12.0"
        assert str(self.t2) == "Triangle with base 10.0 and height 12.0"
        assert str(self.t3) == "Triangle with base 12.0 and height 13.0"

    def test_eq(self):
        assert (self.t1 == self.t2) is False
        assert (self.t2 == self.t3) is False
        assert (self.t2 == self.t4) is True
Beispiel #5
0
class TestTriangle():
    def setup(self):
        self.t1 = Triangle(3, 6)
        self.t2 = Triangle(2, 6)
        self.t3 = Triangle(5, 3)
        self.t4 = Triangle(7, 2)
        self.t5 = Triangle(2, 6)

    def test_area(self):
        assert self.t1.area() == 9
        assert self.t2.area() == 6
        assert self.t3.area() == 7.5
        assert self.t4.area() == 7

    def test_str(self):
        assert str(self.t1) == 'Triangle with base 3.0 and height 6.0'
        assert str(self.t3) == 'Triangle with base 5.0 and height 3.0'

    def test_eq(self):
        assert (self.t1 == self.t2) is False
        assert (self.t2 == self.t5) is True
        assert (self.t3 == self.t4) is False
Beispiel #6
0
    def setup(self):
        self.ss1 = ShapeSet()
        self.t11 = Triangle(3, 6)
        self.t12 = Triangle(5, 2)
        self.c11 = Circle(4)
        self.c12 = Circle(8)
        self.s11 = Square(5)
        self.s12 = Square(6)
        self.s13 = Square(5)
        self.ss1.addShape(self.t11)
        self.ss1.addShape(self.t12)
        self.ss1.addShape(self.c12)
        self.ss1.addShape(self.c11)
        self.ss1.addShape(self.s11)
        self.ss1.addShape(self.s12)
        self.ss1.addShape(self.s13)
        self.l1 = [self.t11, self.t12, self.c12, self.c11, self.s11, self.s12]

        self.ss2 = ShapeSet()
        self.t21 = Triangle(2.0, 7)
        self.t22 = Triangle(2.0, 7)
        self.t23 = Triangle(4, 2)
        self.c21 = Circle(4)
        self.c22 = Circle(4)
        self.s21 = Square(9)
        self.s22 = Square(2)
        self.s23 = Square(2)
        self.s24 = Square(6)
        self.ss2.addShape(self.t21)
        self.ss2.addShape(self.t22)
        self.ss2.addShape(self.c22)
        self.ss2.addShape(self.c21)
        self.ss2.addShape(self.s21)
        self.ss2.addShape(self.s22)
        self.ss2.addShape(self.s23)
        self.l2 = [self.t21, self.c22, self.s21, self.s22]
Beispiel #7
0
 def setup(self):
     self.t1 = Triangle(3, 6)
     self.t2 = Triangle(2, 6)
     self.t3 = Triangle(5, 3)
     self.t4 = Triangle(7, 2)
     self.t5 = Triangle(2, 6)
Beispiel #8
0
 def setup(self):
     self.t1 = Triangle(12, 12)
     self.t2 = Triangle(10, 12)
     self.t3 = Triangle(12, 13)
     self.t4 = Triangle(10, 12)