package com.nisemoe.nise

import com.nisemoe.nise.konata.Replay
import com.nisemoe.nise.konata.compareReplayPair
import org.junit.jupiter.api.Test
import kotlin.test.assertEquals

class HardRockTest {

    @Test
    fun bothAreHR2() {

        val replay1String =
            "[encoded data, 68500 characters]"
        val replay2String =
            "[encoded data, 55912 characters]"

        val replay1 = Replay(replay1String, 4320914433, mods = 24)
        val replay2 = Replay(replay2String, 2472766904, mods = 24)

        val result = compareReplayPair(replay1, replay2)

        // konata returned 49.89228227126237
        assertEquals(26.488827966780512, result.similarity, 1.0)
    }

    @Test
    fun bothAreHR() {

        val replay1String =
            "[encoded data, 44864 characters]"
        val replay2String =
            "[encoded data, 61680 characters]"

        val replay1 = Replay(replay1String, 2895889075, mods = 24)
        val replay2 = Replay(replay2String, 2835156807, mods = 24)

        val result = compareReplayPair(replay1, replay2)

        // konata returned 62.18258527463182
        assertEquals(25.270783917544247, result.similarity, 1.0)
    }

    @Test
    fun hardRockTestJustOneIsHR() {

        val replay1 = Replay(
            "[encoded data, 63548 characters]",
            4503368409,
            24
        )
        val replay2 = Replay(
            "[encoded data, 37988 characters]",
            4185494793,
            8
        )

        val result = compareReplayPair(replay1, replay2)

        // Expected: 135.0680544732193
        assertEquals(28.87651009920229, result.similarity, 1.0)

    }

    @Test
    fun hardRockTestBothAreHR() {

        // 2945180454.*4503368409
        // Replay 1 = 2945180454
        // Replay 2 = 4503368409

        val replay2 = Replay(
            "[encoded data, 63548 characters]",
            4503368409,
            24
        )
        val replay1 = Replay(
            "[encoded data, 62416 characters]",
            2945180454,
            24
        )

        val result = compareReplayPair(replay1, replay2)

        // Expected: 70.16325670510619
        assertEquals(25.4915245720154, result.similarity, 1.0)

    }

}