feature/unit_tests_modularity #4

Merged
sezieru merged 7 commits from feature/unit_tests_modularity into feature/unit_tests 2025-10-13 12:40:34 +00:00
Owner

PR Goal: Modularize Unit Testing for Educational Clarity

Status: Work In Progress (WIP)

Objective

Refactor the unit testing codebase to improve modularity, readability, and educational value by:

  • Splitting comparator functions into individual files.
  • Consolidating test cases in a dedicated header.
  • Updating the build system to support the new structure.

This will:

  • Reduce cognitive load for students by isolating concepts (e.g. one comparator = one file).
  • Make it easier to add/extend tests and comparators.
  • Demonstrate real-world software engineering practices (modularity, separation of concerns).

Requirements Checklist

All tasks must be completed before merging.

  • Split comparators into individual .c files (e.g. cmp_prefix.c, cmp_regex.c).
  • Create comparators.h with prototypes for all comparators.
  • Move test_cases struct and test cases to test_cases.h.
  • Update rc_test.c to include comparators.h and test_cases.h.
  • Update Makefile to compile individual comparator files.
  • Verify all tests pass with make test.
  • Update TESTING.md to document:
    • New file structure.
    • How to add a new comparator/test.
  • Remove obsolete code/comments.

Educational Notes for Reviewers/Students

  • Why this matters:
    • Modularity makes it easier to focus on one concept at a time (e.g. "How does cmp_regex work?").
    • It also mirrors real-world practices, where large codebases are split into logical units.
  • How to test this PR:
    • Run make clean && make to build everything.
    • Run make test to execute tests.
    • Verify output matches expectations (TAP v14 format).
  • Adding a new comparator:
    • Create cmp_new.c and implement the function.
    • Add its prototype to comparators.h.
    • Add the file to SRC_COMPARATORS in the Makefile.
    • Use it in test_cases.h.
  • Adding a new test case:
    • Add the test to the test_cases array in test_cases.h.
    • No Makefile changes needed!

Open Questions/Issues

  • Are there any edge cases or comparators missing from the current design?
  • Should we add a script to automate test case generation (e.g. for common patterns)?

CC: @mentors @students
Reviewrs: Please focus on:

  • Clarity of the new structure for educational purposes.
  • Correctness of the Makefile and build process.
  • Completeness of the documentation updates.

Next Steps:

  • Complete the checklist above.
  • Request a final review once all tasks are done.
  • Merge after approval!

Note: This is a WIP -- feedback welcome as we go!


### PR Goal: Modularize Unit Testing for Educational Clarity **Status:** Work In Progress (WIP) #### **Objective** Refactor the unit testing codebase to improve **modularity**, **readability**, and **educational value** by: - Splitting comparator functions into individual files. - Consolidating test cases in a dedicated header. - Updating the build system to support the new structure. This will: - Reduce cognitive load for students by isolating concepts (e.g. one comparator = one file). - Make it easier to add/extend tests and comparators. - Demonstrate real-world software engineering practices (modularity, separation of concerns). --- #### **Requirements Checklist** **All tasks must be completed before merging.** - [ ] Split comparators into individual `.c` files (e.g. `cmp_prefix.c`, `cmp_regex.c`). - [x] Create `comparators.h` with prototypes for all comparators. - [x] Move `test_cases` struct and test cases to `test_cases.h`. - [x] Update `rc_test.c` to include `comparators.h` and `test_cases.h`. - [ ] Update `Makefile` to compile individual comparator files. - [ ] Verify all tests pass with `make test`. - [ ] Update `TESTING.md` to document: - New file structure. - How to add a new comparator/test. - [ ] Remove obsolete code/comments. --- #### **Educational Notes for Reviewers/Students** - **Why this matters:** - Modularity makes it easier to focus on one concept at a time (e.g. "How does `cmp_regex` work?"). - It also mirrors real-world practices, where large codebases are split into logical units. - **How to test this PR:** - Run `make clean && make` to build everything. - Run `make test` to execute tests. - Verify output matches expectations (TAP v14 format). - **Adding a new comparator:** - Create `cmp_new.c` and implement the function. - Add its prototype to `comparators.h`. - Add the file to `SRC_COMPARATORS` in the `Makefile`. - Use it in `test_cases.h`. - **Adding a new test case:** - Add the test to the `test_cases` array in `test_cases.h`. - No Makefile changes needed! --- #### **Open Questions/Issues** - Are there any edge cases or comparators missing from the current design? - Should we add a script to automate test case generation (e.g. for common patterns)? **CC:** @mentors @students **Reviewrs:** Please focus on: - Clarity of the new structure for educational purposes. - Correctness of the Makefile and build process. - Completeness of the documentation updates. --- **Next Steps:** - [ ] Complete the checklist above. - [ ] Request a final review once all tasks are done. - [ ] Merge after approval! **Note:** This is a WIP -- feedback welcome as we go! ***
Author
Owner

Requirements Checklist - (Update)

All tasks must be completed before merging.

  • Split comparators into individual .c files (e.g. cmp_prefix.c, cmp_regex.c).
  • Create comparators.h with prototypes for all comparators.
  • Move test_cases struct and test cases to test_cases.h.
  • Update rc_test.c to include comparators.h and test_cases.h.
  • Update Makefile to compile individual comparator files.
  • Verify all tests pass with make test.
  • Update TESTING.md to document:
    • New file structure.
    • How to add a new comparator/test.
  • Remove obsolete code/comments.
#### **Requirements Checklist - (Update)** **All tasks must be completed before merging.** - [x] Split comparators into individual `.c` files (e.g. `cmp_prefix.c`, `cmp_regex.c`). - [x] Create `comparators.h` with prototypes for all comparators. - [x] Move `test_cases` struct and test cases to `test_cases.h`. - [x] Update `rc_test.c` to include `comparators.h` and `test_cases.h`. - [x] Update `Makefile` to compile individual comparator files. - [x] Verify all tests pass with `make test`. - [ ] Update `TESTING.md` to document: - New file structure. - How to add a new comparator/test. - [x] Remove obsolete code/comments.
Author
Owner

Requirements Checklist - (Update)

All tasks must be completed before merging.

  • Split comparators into individual .c files (e.g. cmp_prefix.c, cmp_regex.c).
  • Create comparators.h with prototypes for all comparators.
  • Move test_cases struct and test cases to test_cases.h.
  • Update rc_test.c to include comparators.h and test_cases.h.
  • Update Makefile to compile individual comparator files.
  • Verify all tests pass with make test.
  • Update TESTING.md to document:
    • New file structure.
    • How to add a new comparator/test.
  • Remove obsolete code/comments.
#### **Requirements Checklist - (Update)** **All tasks must be completed before merging.** - [x] Split comparators into individual `.c` files (e.g. `cmp_prefix.c`, `cmp_regex.c`). - [x] Create `comparators.h` with prototypes for all comparators. - [x] Move `test_cases` struct and test cases to `test_cases.h`. - [x] Update `rc_test.c` to include `comparators.h` and `test_cases.h`. - [x] Update `Makefile` to compile individual comparator files. - [x] Verify all tests pass with `make test`. - [x] Update `TESTING.md` to document: - New file structure. - How to add a new comparator/test. - [x] Remove obsolete code/comments.
sezieru self-assigned this 2025-10-13 12:38:18 +00:00
Author
Owner

Next Steps:

  • Complete the checklist above.
  • Request a final review once all tasks are done.
  • Merge after approval!
**Next Steps:** - [x] Complete the checklist above. - [x] Request a final review once all tasks are done. - [ ] Merge after approval!
Author
Owner

Next Steps:

  • Complete the checklist above.
  • Request a final review once all tasks are done.
  • Merge after approval!
**Next Steps:** - [x] Complete the checklist above. - [x] Request a final review once all tasks are done. - [x] Merge after approval!
sezieru changed title from WIP: feature/unit_tests_modularity to feature/unit_tests_modularity 2025-10-13 12:39:54 +00:00
sezieru merged commit 04cd57c625 into feature/unit_tests 2025-10-13 12:40:34 +00:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: fosster/rexcrypt#4
No description provided.