package de.arxsilex.maptools.converter.worker

import de.arxsilex.maptools.converter.core.GeoBounds
import de.arxsilex.maptools.converter.core.GeoCircleRegion
import de.arxsilex.maptools.converter.core.GeoRectangleRegion
import kotlin.test.Test
import kotlin.test.assertEquals

class SelectionBoundsCodecTest {
    @Test
    fun `round trip preserves rectangles and circles`() {
        val regions = listOf(
            GeoRectangleRegion(GeoBounds(7.0, 49.0, 8.0, 50.0)),
            GeoCircleRegion(50.5, 8.5, 7.25),
        )

        assertEquals(regions, SelectionBoundsCodec.decode(SelectionBoundsCodec.encode(regions)))
    }

    @Test
    fun `legacy untagged rectangle remains readable`() {
        assertEquals(
            listOf(GeoRectangleRegion(GeoBounds(7.0, 49.0, 8.0, 50.0))),
            SelectionBoundsCodec.decode("7.0,49.0,8.0,50.0"),
        )
    }
}
