-
-
Notifications
You must be signed in to change notification settings - Fork 117
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
49 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
planetiler-core/src/test/java/com/onthegomap/planetiler/util/YamlTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package com.onthegomap.planetiler.util; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
import java.util.ArrayList; | ||
import java.util.HashMap; | ||
import java.util.List; | ||
import java.util.Map; | ||
import org.junit.jupiter.api.Test; | ||
|
||
class YamlTest { | ||
@Test | ||
void testLoadYamlRaw() { | ||
assertEquals(Map.of("a", 1), YAML.load(""" | ||
a: 1 | ||
""", Object.class)); | ||
} | ||
|
||
@Test | ||
void testLoadYamlToClass() { | ||
record Result(int a) {} | ||
assertEquals(new Result(1), YAML.load(""" | ||
a: 1 | ||
""", Result.class)); | ||
} | ||
|
||
@Test | ||
void testLoadLargeYamlList() { | ||
StringBuilder builder = new StringBuilder(); | ||
List<Integer> expected = new ArrayList<>(); | ||
for (int i = 0; i < 500_000; i++) { | ||
builder.append("\n- ").append(i); | ||
expected.add(i); | ||
} | ||
assertEquals(expected, YAML.load(builder.toString(), List.class)); | ||
} | ||
|
||
@Test | ||
void testLoadLargeYamlMap() { | ||
StringBuilder builder = new StringBuilder(); | ||
Map<String, Integer> expected = new HashMap<>(); | ||
for (int i = 0; i < 500_000; i++) { | ||
builder.append('\n').append(i).append(": ").append(i); | ||
expected.put(Integer.toString(i), i); | ||
} | ||
assertEquals(expected, YAML.load(builder.toString(), Map.class)); | ||
} | ||
} |