mirror of
https://github.com/vitorpamplona/amethyst.git
synced 2026-10-06 03:38:23 +00:00
fix(commons): iOS test compile error and CharsetDecoder interop warnings
Kotlin/Native rejects ',' in function names, so the backticked test name in UploadFallbackTest broke compileTestKotlinIosSimulatorArm64. Also opt into BetaInteropApi for NSData/NSString.create and drop the NSString-to-String? cast the compiler flags as only succeeding on null. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019fqLYHsGZQLj55XxoB6RN7
This commit is contained in:
+1
-1
@@ -34,7 +34,7 @@ class UploadFallbackTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `a server is never tried twice, even under another spelling`() {
|
||||
fun `a server is never tried twice even under another spelling`() {
|
||||
val primalAgain = ServerName("primal", "https://BLOSSOM.PRIMAL.NET")
|
||||
assertEquals(listOf(primal, band), blossomUploadOrder(primal, listOf(primalAgain, band, band)))
|
||||
}
|
||||
|
||||
+3
-2
@@ -20,6 +20,7 @@
|
||||
*/
|
||||
package com.vitorpamplona.amethyst.commons.preview
|
||||
|
||||
import kotlinx.cinterop.BetaInteropApi
|
||||
import kotlinx.cinterop.ExperimentalForeignApi
|
||||
import kotlinx.cinterop.addressOf
|
||||
import kotlinx.cinterop.usePinned
|
||||
@@ -41,7 +42,7 @@ import platform.Foundation.create
|
||||
* to their `NSStringEncoding`; anything else falls back to UTF-8 (matching the
|
||||
* "defaults to UTF-8" behaviour of the charset sniffer).
|
||||
*/
|
||||
@OptIn(ExperimentalForeignApi::class)
|
||||
@OptIn(ExperimentalForeignApi::class, BetaInteropApi::class)
|
||||
actual fun decodeBytes(
|
||||
bytes: ByteArray,
|
||||
charsetName: String?,
|
||||
@@ -55,7 +56,7 @@ actual fun decodeBytes(
|
||||
NSData.create(bytes = pinned.addressOf(0), length = bytes.size.toULong())
|
||||
}
|
||||
|
||||
return (NSString.create(data, encoding) as String?)
|
||||
return NSString.create(data = data, encoding = encoding)?.toString()
|
||||
?: bytes.decodeToString()
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user