diff options
| author | Rime <81419447+Emirlol@users.noreply.github.com> | 2025-03-08 07:56:42 +0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-03-07 23:56:42 -0500 |
| commit | fcb762a10e06ae9bb9b23cff0d2745b849ea972a (patch) | |
| tree | ab47df6edf3bc8ed49339dfc47b8a346fe3afa04 /src/test/java | |
| parent | f70cdd8865043e96ebc1e56472e0eb0544efda54 (diff) | |
| download | Skyblocker-fcb762a10e06ae9bb9b23cff0d2745b849ea972a.tar.gz Skyblocker-fcb762a10e06ae9bb9b23cff0d2745b849ea972a.tar.bz2 Skyblocker-fcb762a10e06ae9bb9b23cff0d2745b849ea972a.zip | |
Fix empty validLocations set failing to be decoded (#1197)
* Fix empty `validLocations` set failing to be decoded
* Remove unnecessary override
* Add encode tests
---------
Co-authored-by: Kevinthegreat <92656833+kevinthegreat1@users.noreply.github.com>
Diffstat (limited to 'src/test/java')
| -rw-r--r-- | src/test/java/de/hysky/skyblocker/skyblock/chat/ChatRuleTest.java | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/test/java/de/hysky/skyblocker/skyblock/chat/ChatRuleTest.java b/src/test/java/de/hysky/skyblocker/skyblock/chat/ChatRuleTest.java index 1c5004fc..21831918 100644 --- a/src/test/java/de/hysky/skyblocker/skyblock/chat/ChatRuleTest.java +++ b/src/test/java/de/hysky/skyblocker/skyblock/chat/ChatRuleTest.java @@ -70,4 +70,28 @@ class ChatRuleTest { )).getOrThrow() ); } + + @Test + void codecParseEmptySet() { + Assertions.assertEquals( + EnumSet.noneOf(Location.class), + ChatRule.LOCATION_FIXING_CODEC.parse(JsonOps.INSTANCE, JsonOps.INSTANCE.createList(Stream.empty())).getOrThrow() + ); + } + + @Test + void codecEncode() { + Assertions.assertEquals( + JsonOps.INSTANCE.createList(Stream.empty()), + ChatRule.LOCATION_FIXING_CODEC.encodeStart(JsonOps.INSTANCE, EnumSet.noneOf(Location.class)).getOrThrow() + ); + + Assertions.assertEquals( + JsonOps.INSTANCE.createList(Stream.of(Location.DWARVEN_MINES, Location.WINTER_ISLAND) + .map(Location::asString) + .map(JsonOps.INSTANCE::createString) + ), + ChatRule.LOCATION_FIXING_CODEC.encodeStart(JsonOps.INSTANCE, EnumSet.of(Location.DWARVEN_MINES, Location.WINTER_ISLAND)).getOrThrow() + ); + } } |
