1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- #include <math.h>
- //const float PI_F = 3.14f;
- float customRound(float number) {
- float factor = pow(10, 5);
- return round(number * factor) / factor;
- };
- Describe(circo_geometry)
- {
- It(test1) {
- Circle circo(2);
- Assert::That((int)(customRound(circo.getArea()) * 100), Equals((int)(12.56f * 100)));
- }
- It(test2) {
- Circle circo(2);
- Assert::That((int)(customRound(circo.getPerimeter()) * 100), Equals((int)(12.56f * 100)));
- }
- It(test3) {
- Circle circo(20);
- Assert::That((int)(customRound(circo.getArea()) * 10), Equals((int)(1256.0f * 10)));
- }
- It(test4) {
- Circle circo(20);
- Assert::That((int)(customRound(circo.getPerimeter()) * 10), Equals((int)(125.6f * 10)));
- }
- It(test5) {
- Circle circo(4.4);
- Assert::That((int)(customRound(circo.getArea()) * 10000), Equals((int)(60.7904f * 10000)));
- }
- It(test6) {
- Circle circo(4.4);
- Assert::That((int)(customRound(circo.getPerimeter()) * 1000), Equals((int)(27.632f * 1000)));
- }
- //scroll down for spoilers that are hard to use
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- /*
- It(test7) {
- int randomInt = rand() % 100 + 1; // random number between 1 and 100
- Circle circo(randomInt);
- Assert::That((int)(customRound(circo.getArea()) * 1000000), Equals((int)(PI_F * pow(randomInt, 2) * 1000000)));
- }
- It(test8) {
- int randomInt = rand() % 100 + 1; // random number between 1 and 100
- Circle circo(randomInt);
- Assert::That((int)(customRound(circo.getPerimeter()) * 100000), Equals((int)(2 * PI_F * randomInt * 100000)));
- }
- */
- };
|