package de.arxsilex.maptools.converter.core

import kotlin.test.Test
import kotlin.test.assertEquals
import kotlin.test.assertNull

class InputFileInspectorTest {
    @Test
    fun detectsOsmPbfCaseInsensitively() {
        assertEquals(InputFormat.OSM_PBF, InputFileInspector.detectFormat("Bayern.OSM.PBF"))
        assertEquals(InputFormat.MAPSFORGE_MAP, InputFileInspector.detectFormat("Südtirol.MAP"))
        assertEquals(InputFormat.MAPSFORGE_POI, InputFileInspector.detectFormat("Südtirol.POI"))
        assertEquals(InputFormat.ELEVATION_HGT, InputFileInspector.detectFormat("N50E008.HGT"))
        assertEquals(InputFormat.ELEVATION_GEOTIFF, InputFileInspector.detectFormat("terrain.GeoTIFF"))
        assertEquals(InputFormat.ELEVATION_GEOTIFF, InputFileInspector.detectFormat("terrain.TIF"))
        assertEquals(InputFormat.ELEVATION_ASC, InputFileInspector.detectFormat("terrain.ASC"))
        assertEquals(InputFormat.ELEVATION_DTED, InputFileInspector.detectFormat("terrain.DT2"))
    }

    @Test
    fun prefersTheSpecificCompressedExtension() {
        assertEquals(InputFormat.OSM_XML_GZIP, InputFileInspector.detectFormat("region.osm.gz"))
        assertEquals(InputFormat.OSM_XML_BZIP2, InputFileInspector.detectFormat("region.osm.bz2"))
    }

    @Test
    fun rejectsUnknownFiles() {
        assertNull(InputFileInspector.detectFormat("region.zip"))
    }
}
