mirror of
https://github.com/TheAlgorithms/Java.git
synced 2026-03-13 08:40:43 +08:00
Added surface area of a cuboid (#7293)
* Added surface area of a cuboid Added surface area of a cuboid according to the formula: S = 2 * (ab + ac + bc) * Removed extra white space * Added test for cuboid surface area * fixed syntax error * Removed extra space * Added tests for cuboid surface area that should fail I have added tests for cuboid surface area where one of the parameters is invalid. These should fail.
This commit is contained in:
@@ -16,6 +16,11 @@ class AreaTest {
|
||||
assertEquals(6.0, Area.surfaceAreaCube(1));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSurfaceAreaCuboid() {
|
||||
assertEquals(214.0, Area.surfaceAreaCuboid(5, 6, 7));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSurfaceAreaSphere() {
|
||||
assertEquals(12.566370614359172, Area.surfaceAreaSphere(1));
|
||||
@@ -70,6 +75,12 @@ class AreaTest {
|
||||
void testAllIllegalInput() {
|
||||
assertAll(()
|
||||
-> assertThrows(IllegalArgumentException.class, () -> Area.surfaceAreaCube(0)),
|
||||
()
|
||||
-> assertThrows(IllegalArgumentException.class, () -> Area.surfaceAreaCuboid(0, 1, 2)),
|
||||
()
|
||||
-> assertThrows(IllegalArgumentException.class, () -> Area.surfaceAreaCuboid(1, 0, 2)),
|
||||
()
|
||||
-> assertThrows(IllegalArgumentException.class, () -> Area.surfaceAreaCuboid(1, 2, 0)),
|
||||
()
|
||||
-> assertThrows(IllegalArgumentException.class, () -> Area.surfaceAreaSphere(0)),
|
||||
()
|
||||
|
||||
Reference in New Issue
Block a user