Skip to content

Add ComparableSubject#isAtLeast to Kruth - #519

Closed
veyndan wants to merge 2 commits into
androidx:androidx-mainfrom
veyndan:270612487/kruth-isAtLeast
Closed

veyndan wants to merge 2 commits into
androidx:androidx-mainfrom
veyndan:270612487/kruth-isAtLeast

Conversation

@veyndan

@veyndan veyndan commented Apr 14, 2023

Copy link
Copy Markdown
Contributor

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

@veyndan
veyndan force-pushed the 270612487/kruth-isAtLeast branch from a1558b0 to 222d549 Compare April 14, 2023 14:48
@veyndan
veyndan force-pushed the 270612487/kruth-isAtLeast branch from 222d549 to 59a572d Compare April 14, 2023 15:03
@claraf3
claraf3 requested review from arkivanov and dlam 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
Copy Markdown

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

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
Copy Markdown
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
harryzz pushed a commit to harryzz/compose-multiplatform-core that referenced this pull request Jul 28, 2026
To migrate the tests in `paging-common` from Truth to Kruth, `isAtLeast` needs to be added to Kruth:

https://github.com/androidx/androidx/blob/60fbea9df29f287c669f7ff69f908f398158379a/paging/paging-common/src/test/kotlin/androidx/paging/FlowExtTest.kt#L289-L290

Test: ./gradlew test connectedCheck
Bug: 270612487

This is an imported pull request from androidx#519.

Resolves JetBrains#519
Github-Pr-Head-Sha: 20d36a6
GitOrigin-RevId: fd39ef3
Change-Id: I0ec6bb35ff172a03f43d660615066285d17433c1
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