Skip to content

Commit

Permalink
Add Uuid.MAX
Browse files Browse the repository at this point in the history
  • Loading branch information
hfhbd committed Aug 18, 2024
1 parent f7f01f4 commit 1bd8931
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 0 deletions.
1 change: 1 addition & 0 deletions kotlinx-uuid-core/api/android/kotlinx-uuid-core.api
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public final class app/softwork/uuid/UuidKt {
public static final fun from (Lkotlin/uuid/Uuid$Companion;IJIJI)Lkotlin/uuid/Uuid;
public static synthetic fun from$default (Lkotlin/uuid/Uuid$Companion;IJIJIILjava/lang/Object;)Lkotlin/uuid/Uuid;
public static final fun getClockSequence (Lkotlin/uuid/Uuid;)I
public static final fun getMAX (Lkotlin/uuid/Uuid$Companion;)Lkotlin/uuid/Uuid;
public static final fun getNode (Lkotlin/uuid/Uuid;)J
public static final fun getTimeStamp (Lkotlin/uuid/Uuid;)J
public static final fun getVariant (Lkotlin/uuid/Uuid;)I
Expand Down
1 change: 1 addition & 0 deletions kotlinx-uuid-core/api/jvm/kotlinx-uuid-core.api
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ public final class app/softwork/uuid/UuidKt {
public static final fun from (Lkotlin/uuid/Uuid$Companion;IJIJI)Lkotlin/uuid/Uuid;
public static synthetic fun from$default (Lkotlin/uuid/Uuid$Companion;IJIJIILjava/lang/Object;)Lkotlin/uuid/Uuid;
public static final fun getClockSequence (Lkotlin/uuid/Uuid;)I
public static final fun getMAX (Lkotlin/uuid/Uuid$Companion;)Lkotlin/uuid/Uuid;
public static final fun getNode (Lkotlin/uuid/Uuid;)J
public static final fun getTimeStamp (Lkotlin/uuid/Uuid;)J
public static final fun getVariant (Lkotlin/uuid/Uuid;)I
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,3 +105,5 @@ public fun String.toUuidOrNull(): Uuid? = try {
} catch (_: IllegalArgumentException) {
null
}

public val Uuid.Companion.MAX: Uuid get() = fromLongs(-1, -1)
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ internal const val SOME_UUID_STRING: String = "1b3e4567-e99b-13d3-a476-446657420
class UuidTest {
@Test
fun testZero() {
assertEquals("00000000-0000-0000-0000-000000000000", Uuid.NIL.toString())
assertEquals(0, Uuid.NIL.variant)
assertEquals(0, Uuid.NIL.versionNumber)
assertEquals(0, Uuid.NIL.timeStamp)
Expand All @@ -23,6 +24,17 @@ class UuidTest {
assertEquals(false, Uuid.NIL.isRfcVariant)
}

@Test
fun testMax() {
assertEquals("ffffffff-ffff-ffff-ffff-ffffffffffff", Uuid.MAX.toString())
assertEquals(7, Uuid.MAX.variant)
assertEquals(15, Uuid.MAX.versionNumber)
assertEquals(1152921504606846975, Uuid.MAX.timeStamp)
assertEquals(8191, Uuid.MAX.clockSequence)
assertEquals(281474976710655, Uuid.MAX.node)
assertEquals(false, Uuid.MAX.isRfcVariant)
}

@Test
fun testConstructingFromString() {
val uuid = Uuid.parse(UUID_STRING)
Expand Down

0 comments on commit 1bd8931

Please sign in to comment.