fix: Sort

This commit is contained in:
J-Jamet 2024-11-08 13:27:26 +01:00
parent 587bfdc162
commit 4723fb39e9
3 changed files with 28 additions and 2 deletions

View file

@ -204,6 +204,11 @@ class NodesAdapter (
&& oldItem.type == newItem.type
&& oldItem.title == newItem.title
&& oldItem.icon == newItem.icon
&& oldItem.creationTime == newItem.creationTime
&& oldItem.lastModificationTime == newItem.lastModificationTime
&& oldItem.lastAccessTime == newItem.lastAccessTime
&& oldItem.expiryTime == newItem.expiryTime
&& oldItem.expires == newItem.expires
&& oldItem.isCurrentlyExpires == newItem.isCurrentlyExpires
}

View file

@ -229,8 +229,8 @@ class DateInstant : Parcelable {
return this.mInstant.isAfter(dateInstant.mInstant)
}
fun compareTo(other: DateInstant?): Int {
return mInstant.compareTo(other?.mInstant)
fun compareTo(other: DateInstant): Int {
return mInstant.compareTo(other.mInstant)
}
enum class Type {

View file

@ -165,6 +165,27 @@ class ValuesTest : TestCase() {
assertTrue("jDate $jDate and cDate $cDate not equal", cDate == jDate)
}
fun testDateCompare() {
val dateInstantA = DateInstant().apply {
setDate(2024, 12, 2)
setTime(5, 13)
}
val dateInstantB = DateInstant().apply {
setDate(2024, 12, 2)
setTime(5, 10)
}
val dateInstantC = DateInstant().apply {
setDate(2024, 12, 2)
setTime(5, 10)
}
assertTrue(dateInstantA.compareTo(dateInstantB) > 0)
assertTrue(dateInstantB.compareTo(dateInstantA) < 0)
assertTrue(dateInstantB.compareTo(dateInstantC) == 0)
assertTrue(dateInstantA.isAfter(dateInstantB))
assertTrue(dateInstantB.isBefore(dateInstantA))
assertFalse(dateInstantB.isBefore(dateInstantC))
}
fun testUUID() {
val bUUID = ByteArray(16)
Random().nextBytes(bUUID)