Skip to content

Commit 544d92f

Browse files
committed
Finished with testing
1 parent 0d5ed5e commit 544d92f

File tree

1 file changed

+12
-13
lines changed

1 file changed

+12
-13
lines changed

For loop/50. Decimal to octal.c

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ The Octal of 79 is 117.
2626
+ Function to get the number int
2727
+ Reverse it
2828
+ 5. Output
29-
6. Test
29+
+ 6. Test
3030
+ 7. Cpplint test
3131
+ 8. Add and push
3232
*/
@@ -54,20 +54,19 @@ void test(int number, int expected, int test_number);
5454
void run_tests();
5555

5656
int main() {
57-
// int decimal_number = 0;
58-
// int input_state = input_decimal_number(&decimal_number);
59-
// if (input_state == SUCCESS) {
60-
// int converted = convert(decimal_number);
61-
// print_octal(decimal_number, converted);
62-
// } else {
63-
// print_invalid_input();
64-
// }
57+
int decimal_number = 0;
58+
int input_state = input_decimal_number(&decimal_number);
59+
if (input_state == SUCCESS) {
60+
int converted = convert(decimal_number);
61+
print_octal(decimal_number, converted);
62+
} else {
63+
print_invalid_input();
64+
}
6565
run_tests();
6666
return 0;
6767
}
6868

6969
void run_tests() {
70-
/*
7170
// Normal value tests
7271
test(79, 117, 1);
7372
test(1, 1, 2);
@@ -84,9 +83,8 @@ void run_tests() {
8483
test(0, 0, 11);
8584
// Big number test
8685
test(47483647, 265105377, 12);
87-
*/
88-
// Near end of int range
89-
test(294903430, 2144757206, 13);
86+
// Near end of int range for octal result
87+
test(100903430, 600725006, 13);
9088
}
9189

9290
void test(int number, int expected, int test_number) {
@@ -187,6 +185,7 @@ int number_of_eights(int decimal_number) {
187185
}
188186

189187
int input_decimal_number(int * decimal_number) {
188+
printf("Enter a number to convert:\n");
190189
int input_state = FAILURE;
191190
char endline = '\0';
192191
if (!scanf("%d%c", decimal_number, &endline) || endline != '\n') {

0 commit comments

Comments
 (0)