Updated on 2026-08-14
This commit is contained in:
parent
16b8957165
commit
972a287b1d
3 changed files with 8 additions and 11 deletions
|
|
@ -33,12 +33,9 @@ internal class Version private constructor(value: String) : Comparable<Version>
|
|||
var result = major.compareTo(other.major)
|
||||
if (result == 0) result = minor.compareTo(other.minor)
|
||||
if (result == 0) {
|
||||
when {
|
||||
fix == null && other.fix == null -> result = 0
|
||||
fix == null && other.fix != null -> result = -1
|
||||
fix != null && other.fix == null -> result = 1
|
||||
fix != null && other.fix != null -> result = fix.compareTo(other.fix)
|
||||
}
|
||||
val thisFix = fix ?: 0
|
||||
val otherFix = other.fix ?: 0
|
||||
result = thisFix.compareTo(otherFix)
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
|
|
|||
|
|
@ -101,7 +101,7 @@ internal class VersionTest {
|
|||
|
||||
val actual = one?.compareTo(other)
|
||||
|
||||
Truth.assertThat(actual).isEqualTo(ONE_IS_LESS_THAN_OTHER)
|
||||
Truth.assertThat(actual).isEqualTo(ONE_IS_EQUAL_TO_OTHER)
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -111,7 +111,7 @@ internal class VersionTest {
|
|||
|
||||
val actual = one?.compareTo(other)
|
||||
|
||||
Truth.assertThat(actual).isEqualTo(ONE_IS_GREATER_THAN_OTHER)
|
||||
Truth.assertThat(actual).isEqualTo(ONE_IS_EQUAL_TO_OTHER)
|
||||
}
|
||||
|
||||
private companion object {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue