mirror of
https://github.com/vitorpamplona/amethyst.git
synced 2026-10-06 03:38:23 +00:00
chore(test): fix redundant-cast and deprecated Thread.id warnings
Use assertIs in Nip88PollTagsTest instead of assertTrue + a cast the smart cast already made redundant, and Thread.threadId() in ObserverListBenchmark in place of the deprecated Thread.id. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01MKvUGSMiCwjSdVm33hD4yp
This commit is contained in:
+3
-3
@@ -269,7 +269,7 @@ class ObserverListBenchmark {
|
||||
*/
|
||||
private fun allocatedBytes(): Long {
|
||||
val bean = ManagementFactory.getThreadMXBean() as com.sun.management.ThreadMXBean
|
||||
return bean.getThreadAllocatedBytes(Thread.currentThread().id)
|
||||
return bean.getThreadAllocatedBytes(Thread.currentThread().threadId())
|
||||
}
|
||||
|
||||
private fun measureAllocation(
|
||||
@@ -400,14 +400,14 @@ class ObserverListBenchmark {
|
||||
repeat(threads) { t ->
|
||||
thread {
|
||||
start.await()
|
||||
val before = bean.getThreadAllocatedBytes(Thread.currentThread().id)
|
||||
val before = bean.getThreadAllocatedBytes(Thread.currentThread().threadId())
|
||||
var i = t
|
||||
while (i < ops) {
|
||||
val (e, note) = fx[i % fx.size]
|
||||
subject.new(e, note)
|
||||
i += threads
|
||||
}
|
||||
total.addAndGet(bean.getThreadAllocatedBytes(Thread.currentThread().id) - before)
|
||||
total.addAndGet(bean.getThreadAllocatedBytes(Thread.currentThread().threadId()) - before)
|
||||
done.countDown()
|
||||
}
|
||||
}
|
||||
|
||||
+3
-4
@@ -42,6 +42,7 @@ import kotlin.test.Test
|
||||
import kotlin.test.assertContentEquals
|
||||
import kotlin.test.assertEquals
|
||||
import kotlin.test.assertFalse
|
||||
import kotlin.test.assertIs
|
||||
import kotlin.test.assertNull
|
||||
import kotlin.test.assertTrue
|
||||
|
||||
@@ -91,8 +92,7 @@ class Nip88PollTagsTest {
|
||||
@Test
|
||||
fun theSpecsPollExampleParsesFieldForField() {
|
||||
val event = Event.fromJson(specPoll)
|
||||
assertTrue(event is PollEvent)
|
||||
val poll = event as PollEvent
|
||||
val poll = assertIs<PollEvent>(event)
|
||||
|
||||
assertEquals("Pineapple on pizza", poll.content)
|
||||
assertEquals(listOf("qj518h583" to "Yay", "gga6cdnqj" to "Nay"), poll.options().map { it.code to it.label })
|
||||
@@ -104,8 +104,7 @@ class Nip88PollTagsTest {
|
||||
@Test
|
||||
fun theSpecsResponseExampleParsesFieldForField() {
|
||||
val event = Event.fromJson(specResponse)
|
||||
assertTrue(event is PollResponseEvent)
|
||||
val response = event as PollResponseEvent
|
||||
val response = assertIs<PollResponseEvent>(event)
|
||||
|
||||
assertEquals("1fc80cf813f1af33d5a435862b7ef7fb96b47e68a48f1abcadf8081f5a545550", response.poll()?.eventId)
|
||||
// Both tags are read. Which of them counts is the polltype's business, not the parser's.
|
||||
|
||||
Reference in New Issue
Block a user