Skip to content

Feat: throw an exception instead on testInteger & testLong#1194

Open
SharmaNishchay wants to merge 4 commits into
sqlancer:mainfrom
SharmaNishchay:Dark_1
Open

Feat: throw an exception instead on testInteger & testLong#1194
SharmaNishchay wants to merge 4 commits into
sqlancer:mainfrom
SharmaNishchay:Dark_1

Conversation

@SharmaNishchay

@SharmaNishchay SharmaNishchay commented Mar 30, 2025

Copy link
Copy Markdown
Contributor

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
Copy Markdown
Contributor Author

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

@bhavaniprasad-tech bhavaniprasad-tech left a comment

Copy link
Copy Markdown

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
Copy Markdown

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

SharmaNishchay commented Apr 9, 2025

Copy link
Copy Markdown
Contributor Author

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