package com.example.kotlin_sample

import kotlin.test.BeforeTest
import kotlin.test.AfterTest
import kotlin.test.Test
import kotlin.test.assertEquals
import platform.posix.*
import platform.PerformanceAnalysisKit.HiLog.*

private fun hilogInfo(tag: String, message: String) {
    // 使用 printf 确保 hdc shell 可见
    printf("[$tag][INFO] $message\n")
    
    // 同时写入 HiLog
    OH_LOG_Print(
        0u,
        4u,
        0x0000u, // domain
        tag,
        "%{public}s", // fmt
        message // args
    )
}

class OhosPlatformTest {

    @BeforeTest
    fun setup() {
        hilogInfo("OhosPlatformTest", "Starting test...")
    }

    @AfterTest
    fun tearDown() {
        hilogInfo("OhosPlatformTest", "Test finished.")
    }

    @Test
    fun testGetPlatform() {
        hilogInfo("OhosPlatformTest", "Running testGetPlatform")
        val platformName = getPlatform().name
        hilogInfo("OhosPlatformTest", "Platform name: $platformName")
        assertEquals("HarmonyOS", platformName)
    }
}
