Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ComparableSubject#isAtLeast to Kruth #519

Closed

Conversation

veyndan
Copy link
Contributor

@veyndan veyndan commented Apr 14, 2023

To migrate the tests in paging-common from Truth to Kruth, isAtLeast needs to be added to Kruth:

assertThat(next.first).isAtLeast(acc.first)
assertThat(next.second).isAtLeast(acc.second)

Test: ./gradlew test connectedCheck
Bug: 270612487

@claraf3 claraf3 requested review from dlam and arkivanov and removed request for dlam April 17, 2023 18:11
@arkivanov arkivanov requested a review from dlam April 17, 2023 18:43
* @throws NullPointerException if [actual] or [other] is `null`.
*/
fun isAtLeast(other: T?) {
if (actual == null || other == null) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's use the existing requireNonNull function?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Can do! The implementation was mostly a copy-paste of the isLessThan function above. It could perhaps be simplified there too (in a separate PR).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@arkivanov Replacing this line with requireNotNull would mean an IllegalArgumentException would be thrown instead of a NullPointerException. This diverges from Truth, as their isAtLeast function also throws a NullPointerException. Was the original suggestion to also change the throwable type?

Copy link
Contributor

Choose a reason for hiding this comment

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

I meant our internal function, see

internal inline fun <T : Any> requireNonNull(

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oops, my bad! You had linked it in the first message — I completely overlooked it.

Changed in 20d36a6.

@arkivanov arkivanov requested a review from yigit April 18, 2023 10:07
@veyndan veyndan deleted the 270612487/kruth-isAtLeast branch April 20, 2023 21:43
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