mirror of
https://github.com/TheAlgorithms/Java.git
synced 2025-07-27 22:43:30 +08:00
Created VolumeTest.java & Fixed Bugs in Volume.java (#3682)
* Fixed functions and removed main() in Volume.java Fixed calculation errors in volumeSphere() and volumeHemisphere() functions and removed main() and changed functions access specifier from private to public * Created VolumeTest.java Created VolumeTest.java JUnit Tests for Volume.java Co-authored-by: Debasish Biswas <debasishbsws.abc@gmail.com>
This commit is contained in:

committed by
GitHub

parent
bd267bb7d8
commit
5ab1b6c319
35
src/test/java/com/thealgorithms/maths/VolumeTest.java
Normal file
35
src/test/java/com/thealgorithms/maths/VolumeTest.java
Normal file
@ -0,0 +1,35 @@
|
||||
package com.thealgorithms.maths;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
public class VolumeTest {
|
||||
|
||||
@Test
|
||||
public void volume() {
|
||||
|
||||
/* test cube */
|
||||
assertTrue(Volume.volumeCube(7) == 343.0);
|
||||
|
||||
/* test cuboid */
|
||||
assertTrue(Volume.volumeCuboid(2, 5, 7) == 70.0);
|
||||
|
||||
/* test sphere */
|
||||
assertTrue(Volume.volumeSphere(7) == 1436.7550402417319);
|
||||
|
||||
/* test cylinder */
|
||||
assertTrue(Volume.volumeCylinder(3, 7) == 197.92033717615698);
|
||||
|
||||
/* test hemisphere */
|
||||
assertTrue(Volume.volumeHemisphere(7) == 718.3775201208659);
|
||||
|
||||
/* test cone */
|
||||
assertTrue(Volume.volumeCone(3, 7) == 65.97344572538566);
|
||||
|
||||
/* test prism */
|
||||
assertTrue(Volume.volumePrism(10, 2) == 20.0);
|
||||
|
||||
/* test pyramid */
|
||||
assertTrue(Volume.volumePyramid(10, 3) == 10.0);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user