Skip to content

Commit

Permalink
test: added a test for loading a .tmx map with an error
Browse files Browse the repository at this point in the history
  • Loading branch information
AlmasB committed Apr 14, 2023
1 parent 6e3d3e8 commit 7d58705
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ package com.almasb.fxgl.entity.level.tiled

import com.almasb.fxgl.entity.*
import com.almasb.fxgl.entity.components.IDComponent
import com.almasb.fxgl.entity.level.LevelLoadingException
import com.almasb.fxgl.test.RunWithFX
import javafx.geometry.Point2D
import javafx.scene.image.ImageView
Expand All @@ -17,8 +18,7 @@ import javafx.scene.shape.Polyline
import org.hamcrest.CoreMatchers.`is`
import org.hamcrest.CoreMatchers.not
import org.hamcrest.MatcherAssert.assertThat
import org.junit.jupiter.api.Assertions.assertFalse
import org.junit.jupiter.api.Assertions.assertTrue
import org.junit.jupiter.api.Assertions.*
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.extension.ExtendWith
import org.junit.jupiter.params.ParameterizedTest
Expand Down Expand Up @@ -207,6 +207,18 @@ class TMXLevelLoaderTest {
assertThat(level.entities.size, `is`(2))
}

@Test
fun `Load a map with an error`() {
val world = GameWorld()

val e = assertThrows(LevelLoadingException::class.java) {
TMXLevelLoader().load(javaClass.getResource("map_with_error.tmx"), world)
}

assertNotNull(e.message)
assertTrue(e.message!!.isNotEmpty())
}

@ParameterizedTest
@CsvSource("sewers_v1_1_2.tmx", "sewers_v1_2_3.tmx", "sewers_v1_9_0.tmx")
fun parse(mapName: String) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<map version="1.9" tiledversion="1.9.0" orientation="orthogonal" renderorder="right-down" width="64" height="64" tilewidth="24" tileheight="24" infinite="0" nextlayerid="5" nextobjectid="7">
<tileset firstgid="1" name="sewer_tileset" tilewidth="24" tileheight="24" tilecount="72" columns="8">
<image source="sewer_tileset.png" trans="ff00ff" width="192" height="217"/>
</tileset>
<layer id="1" name="Bottom" width="64" height="64">
<data encoding="base64" compression="zlib">
eJztmN1qwkAQRpfeabWgFaHqja1af97D93+kjpiBZdikmwTd7Ho+OFCMRc+E4Vszdc59CN8VE2HqvfYjbCq25rp/LfSetvjfw372f3SN/Vz84/13wlnYV9z+PmTuvxDehGWEf4n3fySMhfce/jrDtujMU/rPhLnw2cNfZxjit+Gazlz36pLA39LFX2focwy8ZgnNPDf/k7vfuz60ue9D679UDMX/S1gJ6xf13wb+b8j+tnf69r/uf5cdTuHv905M//vzKWH//d6J6X9/PiXsf13v1fXfbT7Xaj4l7H+bLrbdHtrx3PY/xa7ijz/++fhrp1me3XGp/LXTmroxNY/2t8+0Svn9F+tvn2mVcv6N9bfPtOrOv6X667l37prPvyX61z3TevYZN5V/DuCPP/74448//vjjjz/++OOPP/74448//vjjjz8hhBBCCCGEkNfLHzZhCrU=
</data>
</layer>
<layer id="2" name="Top" width="64" height="64" opacity="0.49">
<data encoding="base64" compression="zlib">
eJzt1zEOwjAQRFEXhCrJVVKEQIHouP+Z2CK+AhPJ70lfbsfltnYtz

0 comments on commit 7d58705

Please sign in to comment.