From 3e3f501b9b12b1e4077e7e8ca401fe16ec3bfc82 Mon Sep 17 00:00:00 2001 From: k1ngsterr1 Date: Sat, 11 Apr 2026 20:47:18 +0500 Subject: [PATCH] =?UTF-8?q?test:=20=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8?= =?UTF-8?q?=D1=82=D1=8C=20unit=20=D1=82=D0=B5=D1=81=D1=82=D1=8B=20=D0=B4?= =?UTF-8?q?=D0=BB=D1=8F=20helper=20=D1=84=D1=83=D0=BD=D0=BA=D1=86=D0=B8?= =?UTF-8?q?=D0=B9=20=D0=B7=D0=B0=D0=BF=D0=B8=D1=81=D0=B8=20=D0=B3=D0=BE?= =?UTF-8?q?=D0=BB=D0=BE=D1=81=D0=B0,=20=D0=BE=D1=87=D0=B8=D1=81=D1=82?= =?UTF-8?q?=D0=BA=D0=B0=20=D1=81=D1=82=D0=B0=D1=80=D0=BE=D0=B3=D0=BE=20UI?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 4.6 (1M context) --- .../ui/chats/input/ChatDetailInput.kt | 4 +- .../ui/chats/input/VoiceRecordHelpersTest.kt | 65 +++++++++++++++++++ 2 files changed, 67 insertions(+), 2 deletions(-) create mode 100644 app/src/test/java/com/rosetta/messenger/ui/chats/input/VoiceRecordHelpersTest.kt diff --git a/app/src/main/java/com/rosetta/messenger/ui/chats/input/ChatDetailInput.kt b/app/src/main/java/com/rosetta/messenger/ui/chats/input/ChatDetailInput.kt index d228b0f..819aeb7 100644 --- a/app/src/main/java/com/rosetta/messenger/ui/chats/input/ChatDetailInput.kt +++ b/app/src/main/java/com/rosetta/messenger/ui/chats/input/ChatDetailInput.kt @@ -108,7 +108,7 @@ private fun bytesToHexLower(bytes: ByteArray): String { return out.toString() } -private fun compressVoiceWaves(source: List, targetLength: Int): List { +internal fun compressVoiceWaves(source: List, targetLength: Int): List { if (targetLength <= 0) return emptyList() if (source.isEmpty()) return List(targetLength) { 0f } if (source.size == targetLength) return source @@ -142,7 +142,7 @@ private fun compressVoiceWaves(source: List, targetLength: Int): List(), compressVoiceWaves(listOf(1f), 0)) + } + + @Test + fun `compressVoiceWaves upsamples via interpolation`() { + val source = listOf(0.0f, 1.0f) + val result = compressVoiceWaves(source, 3) + assertEquals(3, result.size) + assertEquals(0.0f, result[0], 0.01f) + assertEquals(0.5f, result[1], 0.01f) + assertEquals(1.0f, result[2], 0.01f) + } +}