Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
/*
* Nextcloud Android Library
*
* SPDX-FileCopyrightText: 2023-2024 Nextcloud GmbH and Nextcloud contributors
* SPDX-FileCopyrightText: 2023-2026 Nextcloud GmbH and Nextcloud contributors
* SPDX-FileCopyrightText: 2026 Alper Ozturk <alper.ozturk@nextcloud.com>
* SPDX-FileCopyrightText: 2023 Tobias Kaminsky <tobias@kaminsky.me>
* SPDX-License-Identifier: MIT
*/
Expand All @@ -19,10 +20,14 @@ enum class E2EVersion(

val value: String = values.last()

var unknownValue: String? = null

companion object {
fun max(): E2EVersion = V2_1

@JvmStatic
fun fromValue(v: String?): E2EVersion = entries.find { v in it.values } ?: UNKNOWN
fun fromValue(v: String?): E2EVersion =
entries.find { v in it.values }
?: UNKNOWN.also { it.unknownValue = v }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,13 @@ class E2EVersionTests {
assertEquals(E2EVersion.UNKNOWN, E2EVersion.fromValue(null))
}

@Test
fun testFromValueWhenGiven3Dot0ShouldReturnTrue() {
val version = E2EVersion.fromValue("3.0")
assertEquals(E2EVersion.UNKNOWN, version)
assertEquals("3.0", version.unknownValue)
}

@Test
fun testValues() {
assertEquals(E2EVersion.V1_0.value, "1.0")
Expand Down
Loading