package de.gurkenlabs.litiengine.environment.tilemap.xml;

import static org.junit.jupiter.api.Assertions.assertEquals;

import org.junit.jupiter.api.Test;

import de.gurkenlabs.litiengine.environment.tilemap.IMap;
import de.gurkenlabs.litiengine.resources.Resources;
import de.gurkenlabs.litiengine.util.io.XmlUtilities;

public class TmxCompatibilityTests {
  @Test
  public void infiniteMapNeedsToBeCompatibleToDefaultTmxFormat() {
    
    String source = "tests/de/gurkenlabs/litiengine/environment/tilemap/xml/test-infinite-map.tmx";
    String target = "tests/de/gurkenlabs/litiengine/environment/tilemap/xml/test-map-out.tmx";
    IMap map = Resources.maps().get(source);
    XmlUtilities.save(map, target);

    String original = Resources.read(source);
    String output = Resources.read(target);

    assertEquals(original, output);
  }
  
  @Test
  public void mapObjectMapNeedsToBeCompatibleToDefaultTmxFormat() {
    
    String source = "tests/de/gurkenlabs/litiengine/environment/tilemap/xml/test-mapobject.tmx";
    String target = "tests/de/gurkenlabs/litiengine/environment/tilemap/xml/test-map-out.tmx";
    IMap map = Resources.maps().get(source);
    XmlUtilities.save(map, target);

    String original = Resources.read(source);
    String output = Resources.read(target);

    assertEquals(original, output);
  }
}

@@ -830,24 +830,52 @@
 inal, output
+.replaceAll(%22%5C%5Cr%5C%5Cn?%22, %22%5Cn%22)
 );%0A  %7D%0A  %0A  
@@ -1351,16 +1351,44 @@
 , output
+.replaceAll(%22%5C%5Cr%5C%5Cn?%22, %22%5Cn%22)
 );%0A  %7D%0A%7D

Fix unit test by using unix style line endings.