Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@SharmaNishchay
Copy link
Contributor

@SharmaNishchay SharmaNishchay commented Mar 30, 2025

Closes #1161

@SharmaNishchay SharmaNishchay changed the title TODO: throw an exception instead on testInteger TODO: throw an exception instead on testInteger & testLong Mar 30, 2025
@SharmaNishchay SharmaNishchay changed the title TODO: throw an exception instead on testInteger & testLong Feat: throw an exception instead on testInteger & testLong Mar 30, 2025
@SharmaNishchay
Copy link
Contributor Author

@mrigger The checks are passing. Please review the changes. Thanks!

Copy link

@bhavaniprasad-tech bhavaniprasad-tech left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@test
public void testIntegerValidRange() {
Randomly r = new Randomly();
for (int i = 0; i < 100; i++) {
int val = r.getInteger(5, 10);
assertTrue(val >= 5 && val <= 10);
}
}

@bhavaniprasad-tech
Copy link

Add input validation for getInteger() and update corresponding test

  • Added a check in Randomly.getInteger(left, right) to throw IllegalArgumentException when left > right
  • Updated testInteger() in TestRandomly.java to assert this exception
  • Ensures safer and more predictable behavior for invalid input ranges

@SharmaNishchay
Copy link
Contributor Author

SharmaNishchay commented Apr 9, 2025

Add input validation for getInteger() and update corresponding test

  • Added a check in Randomly.getInteger(left, right) to throw IllegalArgumentException when left > right
  • Updated testInteger() in TestRandomly.java to assert this exception
  • Ensures safer and more predictable behavior for invalid input ranges

I think the testLong2() method already handles that scenario.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

TODO: Add Exception for TestRandomly.java

2 participants