Skip to content

Commit e4816dc

Browse files
committed
Started with test this time
1 parent 7435d3f commit e4816dc

File tree

1 file changed

+26
-1
lines changed

1 file changed

+26
-1
lines changed

For loop/52. Sum of GP series.c

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ The numbers for the G.P. series:
1010
3.000000 6.000000 12.000000 24.000000 48.000000
1111
The Sum of the G.P. series : 93.000000
1212
13-
1. Write tests (run tests function + body of a test)
13+
+ 1. Write tests (run tests function + body of a test)
1414
2. Input
1515
3. Invalid input
1616
4. Finction to print out and find the sum
@@ -21,6 +21,31 @@ The Sum of the G.P. series : 93.000000
2121

2222
#include <stdio.h>
2323

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+
2428
int main() {
29+
run_test();
2530
return 0;
2631
}
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

Comments
 (0)