Skip to content

Commit

Permalink
chore: added tests now one for each function.
Browse files Browse the repository at this point in the history
  • Loading branch information
rbevin777 committed Aug 5, 2023
1 parent 6020dba commit bd6726f
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions math/area.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,48 @@ static void test_cube_surface_area_functionality() {
std::cout << "TEST PASSED: Cube Surface Area" << std::endl << std::endl;
}

/**
* @brief This self test is used to test the basic functionality of the
* sphere_surface_area function to see if it behaves as expected.
* @returns void
*/
static void test_sphere_surface_area_functionality() {
// Given we the radius of the sphere.
uint16_t sphere_radius = 5678u;

// When we calculate the sphere surface area.
uint64_t actual_sphere_surface_area =
math::sphere_surface_area(sphere_radius);

// Then we should get the area calculated as we expect.
// is the expected == actual?
assert(405135817 == actual_sphere_surface_area);

std::cout << "TEST PASSED: Sphere Surface Area" << std::endl << std::endl;
}

/**
* @brief This self test is used to test the basic functionality of the
* cylinder_surface_area function to see if it behaves as expected.
* @returns void
*/
static void test_cylinder_surface_area_functionality() {
// Given we the radius and the height of the cylinder.
uint16_t cylinder_radius = 42u;
uint16_t cylinder_height = 413u;

// When we calculate the cylinder surface area.
uint64_t actual_cylinder_surface_area =
math::cylinder_surface_area(cylinder_radius, cylinder_height);

// Then we should get the area calculated as we expect.
// is the expected == actual?
assert(120071 == actual_cylinder_surface_area);

std::cout << "TEST PASSED: Sphere Surface Area" << std::endl
<< std::endl; // sphere_surface_area
}

/**
* @brief Main function
* @returns 0 on exit
Expand All @@ -280,5 +322,7 @@ int main() {
test_circle_area_functionality();
test_parallelogram_area_functionality();
test_cube_surface_area_functionality();
test_sphere_surface_area_functionality();
test_cylinder_surface_area_functionality();
return 0;
}

0 comments on commit bd6726f

Please sign in to comment.