def test_triangularVolume(self): self.assertAlmostEqual(Volume.triangular(0, 1, 1), 0) self.assertAlmostEqual(Volume.triangular(1, 0, 1), 0) self.assertAlmostEqual(Volume.triangular(1, 1, 0), 0) self.assertAlmostEqual(Volume.triangular(1, 1, 1), 0.5) self.assertAlmostEqual(Volume.triangular(2, 2, 2), 0.5 * 2 * 2 * 2)
def test_pyramidVolume(self): self.assertAlmostEqual(Volume.pyramid(0, 1), 0) self.assertAlmostEqual(Volume.pyramid(0, 0), 0) self.assertAlmostEqual(Volume.pyramid(1, 0), 0) self.assertAlmostEqual(Volume.pyramid(1, 1), 1 / 3) self.assertAlmostEqual(Volume.pyramid(2, 2), (1 / 3) * (2**2) * 2)
def test_ellipsoidVolume(self): self.assertAlmostEqual(Volume.ellipsoid(0, 1, 1), 0) self.assertAlmostEqual(Volume.ellipsoid(1, 0, 1), 0) self.assertAlmostEqual(Volume.ellipsoid(1, 1, 0), 0) self.assertAlmostEqual(Volume.ellipsoid(1, 1, 1), (4 / 3) * math.pi) self.assertAlmostEqual(Volume.ellipsoid(2, 2.5, 5), (4 / 3) * math.pi * 2 * 2.5 * 5)
def test_sphereVolume(self): self.assertEqual(Volume.sphere(0), 0) self.assertEqual(Volume.sphere(1), math.pi * (4 / 3)) self.assertEqual(Volume.sphere(2.5), (4 / 3) * math.pi * 2.5**3)
def test_cylinderVolume(self): self.assertAlmostEqual(Volume.cylinder(0, 1), 0) self.assertAlmostEqual(Volume.cylinder(1, 0), 0) self.assertAlmostEqual(Volume.cylinder(1, 1), math.pi) self.assertAlmostEqual(Volume.cylinder(2.5, 2), math.pi * (2.5**2) * 2)
def test_rectangularVolume(self): self.assertEqual(Volume.rectangular(0, 1, 2), 0) self.assertEqual(Volume.rectangular(1, 0, 3), 0) self.assertEqual(Volume.rectangular(1, 2, 0), 0) self.assertEqual(Volume.rectangular(1, 1, 1), 1) self.assertEqual(Volume.rectangular(2, 2, 2), 2 * 2 * 2)
def test_cubeVolume(self): self.assertEqual(Volume.cube(0), 0) self.assertEqual(Volume.cube(1), 1) self.assertEqual(Volume.cube(2), 8)
def test_irregularVolume(self): self.assertAlmostEqual(Volume.irregular(0, 1), 0) self.assertAlmostEqual(Volume.irregular(1, 0), 0) self.assertAlmostEqual(Volume.irregular(1, 1), 1) self.assertAlmostEqual(Volume.irregular(2.5, 2), 2.5 * 2)
def test_coneVolume(self): self.assertAlmostEqual(Volume.cone(0, 1), 0) self.assertAlmostEqual(Volume.cone(1, 0), 0) self.assertAlmostEqual(Volume.cone(1, 1), math.pi * (1 / 3)) self.assertAlmostEqual(Volume.cone(2.5, 2), (1 / 3) * math.pi * (2.5**2) * 2)