◐ Shell
clean mode source ↗

Feat: throw an exception instead on testInteger & testLong by SharmaNishchay · Pull Request #1194 · sqlancer/sqlancer

@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

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

bhavaniprasad-tech

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

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

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.