コード例 #1
0
    def testIntegerBaseHeight(self):
        base = 12
        height = 15

        result = triangle.triangle_area(base, height)
        expected = base * height * 0.5

        self.assertEqual(result, expected, self.errorMessage)
コード例 #2
0
    def testNonZeroBaseZeroHeight(self):
        base = 15.123
        height = 0

        result = triangle.triangle_area(base, height)
        expected = base * height * 0.5

        self.assertAlmostEqual(result,
                               expected,
                               places=7,
                               msg=self.errorMessage,
                               delta=0.0000001)
コード例 #3
0
    def testIntegerBaseFloatHeight(self):
        base = 12
        height = 15.123

        result = triangle.triangle_area(base, height)
        expected = base * height * 0.5

        self.assertAlmostEqual(result,
                               expected,
                               places=7,
                               msg=self.errorMessage,
                               delta=0.0000001)