From 0e452b47a2226aa664b6c7f2ef06f0b0fd21aaa5 Mon Sep 17 00:00:00 2001 From: Krasimir Date: Sun, 1 Dec 2024 17:28:05 +0100 Subject: [PATCH] test --- .github/workflows/classroom.yml | 39 +++++++++++++++++++++++---------- assignment.c | 8 +++---- 2 files changed, 31 insertions(+), 16 deletions(-) diff --git a/.github/workflows/classroom.yml b/.github/workflows/classroom.yml index e024ee3..a87d57a 100644 --- a/.github/workflows/classroom.yml +++ b/.github/workflows/classroom.yml @@ -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 diff --git a/assignment.c b/assignment.c index 7af1449..7f2d903 100644 --- a/assignment.c +++ b/assignment.c @@ -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; } @@ -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; }