Skip to content

Test an invariant of ActivitySelection - #74

Open
hotasourav8-sketch wants to merge 1 commit into
S-AI-Projects:masterfrom
hotasourav8-sketch:student/e26b07f0855/R45-T024
Open

hotasourav8-sketch wants to merge 1 commit into
S-AI-Projects:masterfrom
hotasourav8-sketch:student/e26b07f0855/R45-T024

Conversation

@hotasourav8-sketch

Copy link
Copy Markdown

Description
This PR adds formal invariant tests for ActivitySelection.activitySelection(). It verifies that the core properties of the greedy interval scheduling problem are always maintained, specifically mutual non-overlap, index validity and uniqueness, finish-time monotonicity, and extremal selection boundaries.

Related Issue
Fixes: #24

Type of Change
● Tests

Changes Made

  • Created ActivitySelectionInvariantTest.java.
  • Added invariant check assertNoOverlap() to mathematically prove zero collision among selected activities.
  • Added uniqueness and bounds check assertValidAndUniqueIndices().
  • Tested monotonic end-time ordering.
  • Tested complete selection for disjoint intervals and singleton selection for fully overlapping intervals.
  • Tested adjacent intervals touching at boundary timestamps.

Screenshots / Recordings
N/A (Backend / Unit test changes only)

Testing
Executed JUnit 5 test suite:
mvn test -Dtest=ActivitySelectionInvariantTest

Checklist
● I have tested my changes locally.
● I have added or updated tests, if needed.
● I have updated documentation, if needed.
● I have followed the project's coding guidelines.
● I have run the relevant tests and checks.
● I have addressed previous review feedback, if applicable.

Additional Notes
Provides formal test coverage for algorithmic correctness of interval scheduling.

Add invariant tests verifying:
- INV-1: Non-overlapping property of selected activities
- INV-2: Validity and uniqueness of returned activity indices
- INV-3: End-time monotonicity in greedy choice sequence
- INV-4: Cardinality bounds (1 <= |selected| <= n)
- INV-5: Complete selection when all activities are mutually disjoint
- INV-6: Singleton selection when all activities mutually overlap
- Boundary handling for back-to-back intervals sharing boundary points

Fixes: S-AI-Projects#24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant