@@ -10,7 +10,7 @@ The numbers for the G.P. series:
10
10
3.000000 6.000000 12.000000 24.000000 48.000000
11
11
The Sum of the G.P. series : 93.000000
12
12
13
- 1. Write tests (run tests function + body of a test)
13
+ + 1. Write tests (run tests function + body of a test)
14
14
2. Input
15
15
3. Invalid input
16
16
4. Finction to print out and find the sum
@@ -21,6 +21,31 @@ The Sum of the G.P. series : 93.000000
21
21
22
22
#include <stdio.h>
23
23
24
+ void test (int first_number , int number_of_terms , int common_ratio , int expected_result , int test_number );
25
+ void run_tests ();
26
+ int find_gp_series (int first , int number_of_terms , int common_ratio );
27
+
24
28
int main () {
29
+ run_test ();
25
30
return 0 ;
26
31
}
32
+
33
+ int find_gp_series (int first , int number_of_terms , int common_ratio ) {
34
+ int sum = 0 ;
35
+ return sum ;
36
+ }
37
+
38
+ void test (int first_number , int number_of_terms , int common_ratio , int expected_result , int test_number ) {
39
+ int actual_result = find_gp_series (first_number , number_of_terms , common_ratio );
40
+ if (actual_result == expected_result ) {
41
+ printf ("Test #%d: Success\n" , test_number );
42
+ } else {
43
+ printf ("Test #%d: Failed\nFirst_number = %d, number_of_terms = %d, common_ratio = %d, expected_result = %d, actual_result = %d\n" ,
44
+ test_number , first_number , number_of_terms , common_ratio , expected_result , actual_result );
45
+ }
46
+ }
47
+
48
+ void run_tests () {
49
+ // Normal value tests
50
+ test (3 , 5 , 2 , 93 , 1 );
51
+ }
0 commit comments