Skip to content

Conversation

@emopers
Copy link

@emopers emopers commented Jul 19, 2019

These tests calls of Cursor.next() without checking if there are any elements to iterate over. Because the method is public and the iterators are obtained from inputs, they could be invalid (e.g., an empty list). This could lead to an exception. This pull request adds a 'hasNext()' check.

Copy link
Member

@ctrueden ctrueden left a comment

Choose a reason for hiding this comment

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

Thanks @emopers. These changes certainly seem like a good idea to me. @tpietzsch What do you think? It's only additional sanity checks in the tests, so no performance impact on the library. My only (nitpicking) concerns are:

  1. Consistency of which kind of exception to throw if things go awry; and
  2. The "fix spacing" commit would ideally be squashed into the first commit, which would follow best practices for its commit message.

{
if ( !dst.hasNext() )
{
throw new NoSuchElementException("Cursor does not have next element");
Copy link
Member

Choose a reason for hiding this comment

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

Would it not be better to call JUnit's fail method here, for consistency? These methods, while public, are only intended for use from unit tests, right?

{
if ( !dst.hasNext() )
{
throw new NoSuchElementException("Cursor dst does not have next element");
Copy link
Member

Choose a reason for hiding this comment

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

Similarly: should we use fail here?

@ctrueden
Copy link
Member

Upon further reflection, I am ambivalent about this. See #259 (comment)

@ctrueden ctrueden closed this Aug 16, 2019
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.

2 participants