Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
Krasimir committed Dec 1, 2024
1 parent eede40f commit 0e452b4
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 16 deletions.
39 changes: 27 additions & 12 deletions .github/workflows/classroom.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,30 +35,45 @@ jobs:
run: |
echo "Debugging No Args Test"
echo "Running command: ./assignment"
./assignment || true
echo "Expected output: Incorrect usage. You provided 0 arguments. The correct number of arguments is 2"
echo "Actual output:"
./assignment
OUTPUT=$(./assignment || true)
echo "Expected output: 'Incorrect usage. You provided 0 arguments. The correct number of arguments is 2'"
echo "Actual output: '$OUTPUT'"
if [ "$OUTPUT" != "Incorrect usage. You provided 0 arguments. The correct number of arguments is 2" ]; then
echo "❌ Test failed!"
exit 1
else
echo "✅ Test passed!"
fi
- name: One arg test
id: one-arg-test
run: |
echo "Debugging One Arg Test"
echo "Running command: ./assignment 1"
./assignment 1 || true
echo "Expected output: Incorrect usage. You provided 1 arguments. The correct number of arguments is 2"
echo "Actual output:"
./assignment 1
OUTPUT=$(./assignment 1 || true)
echo "Expected output: 'Incorrect usage. You provided 1 arguments. The correct number of arguments is 2'"
echo "Actual output: '$OUTPUT'"
if [ "$OUTPUT" != "Incorrect usage. You provided 1 arguments. The correct number of arguments is 2" ]; then
echo "❌ Test failed!"
exit 1
else
echo "✅ Test passed!"
fi
- name: Three args test
id: three-args-test
run: |
echo "Debugging Three Args Test"
echo "Running command: ./assignment 1 2 3"
./assignment 1 2 3 || true
echo "Expected output: Incorrect usage. You provided 3 arguments. The correct number of arguments is 2"
echo "Actual output:"
./assignment 1 2 3
OUTPUT=$(./assignment 1 2 3 || true)
echo "Expected output: 'Incorrect usage. You provided 3 arguments. The correct number of arguments is 2'"
echo "Actual output: '$OUTPUT'"
if [ "$OUTPUT" != "Incorrect usage. You provided 3 arguments. The correct number of arguments is 2" ]; then
echo "❌ Test failed!"
exit 1
else
echo "✅ Test passed!"
fi
- name: Autograding Reporter
uses: classroom-resources/autograding-grading-reporter@v1
Expand Down
8 changes: 4 additions & 4 deletions assignment.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,17 @@ int main(int argc, char *argv[]) {
// Validate the number of arguments provided
if (argc == 1) {
// No arguments provided
printf("Incorrect usage. You provided 0 arguments. The correct number of arguments is 2\n");
printf("Incorrect usage. You provided 0 arguments. The correct number of arguments is 2");
fflush(stdout); // Ensure the output is flushed
return 1;
} else if (argc == 2) {
// Only one argument provided
printf("Incorrect usage. You provided 1 arguments. The correct number of arguments is 2\n");
printf("Incorrect usage. You provided 1 arguments. The correct number of arguments is 2");
fflush(stdout); // Ensure the output is flushed
return 1;
} else if (argc > 3) {
// More than two arguments provided
printf("Incorrect usage. You provided %d arguments. The correct number of arguments is 2\n", argc - 1);
printf("Incorrect usage. You provided %d arguments. The correct number of arguments is 2", argc - 1);
fflush(stdout); // Ensure the output is flushed
return 1;
}
Expand All @@ -29,7 +29,7 @@ int main(int argc, char *argv[]) {
int cols = atoi(argv[2]);

if (rows <= 0 || cols <= 0) {
printf("Incorrect usage. The parameters you provided are not positive integers\n");
printf("Incorrect usage. The parameters you provided are not positive integers");
fflush(stdout); // Ensure the output is flushed
return 1;
}
Expand Down

0 comments on commit 0e452b4

Please sign in to comment.