From ad3de24792c658ec4ccdfdc5d4f1f9392ba78651 Mon Sep 17 00:00:00 2001 From: Collin Smith Date: Thu, 31 Dec 2020 01:44:47 -0800 Subject: [PATCH] Improved test cases for MonPreset table --- .../riiablo/table/table/MonPresetTable.java | 8 ++++++- .../java/com/riiablo/table/TablesTest.java | 21 ++++++++++++++++--- 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/core/src/main/java/com/riiablo/table/table/MonPresetTable.java b/core/src/main/java/com/riiablo/table/table/MonPresetTable.java index 8e6cbdb4..233b12ba 100644 --- a/core/src/main/java/com/riiablo/table/table/MonPresetTable.java +++ b/core/src/main/java/com/riiablo/table/table/MonPresetTable.java @@ -6,6 +6,8 @@ import javax.annotation.Generated; import com.badlogic.gdx.utils.IntArray; import com.riiablo.Riiablo; +import com.riiablo.logger.LogManager; +import com.riiablo.logger.Logger; import com.riiablo.table.Parser; import com.riiablo.table.ParserInput; import com.riiablo.table.Serializer; @@ -20,6 +22,8 @@ import com.riiablo.table.serializer.MonPresetSerializer; comments = "com.riiablo.table.schema.MonPreset" ) public final class MonPresetTable extends Table { + private static final Logger log = LogManager.getLogger(MonPresetTable.class); + public MonPresetTable() { super(MonPreset.class, 53, 0.8f); } @@ -72,7 +76,9 @@ public final class MonPresetTable extends Table { @Override protected void put(int id, MonPreset record) { super.put(id, record); - lookup[record.Act].add(id); + final IntArray lookup = this.lookup[record.Act]; + lookup.add(id); + log.trace("lookup[{}][{}] = {} ({})", record.Act, lookup.size - 1, record, id); } public MonPreset get(int act, int id) { diff --git a/core/src/test/java/com/riiablo/table/TablesTest.java b/core/src/test/java/com/riiablo/table/TablesTest.java index a2f1c4f1..9af205dd 100644 --- a/core/src/test/java/com/riiablo/table/TablesTest.java +++ b/core/src/test/java/com/riiablo/table/TablesTest.java @@ -213,8 +213,23 @@ public class TablesTest extends RiiabloTest { TableManifest.monpreset.parser = null; FileHandle handle = Gdx.files.internal("test/monpreset.txt"); MonPresetTable table = Tables.loadTsv(TableManifest.monpreset, handle); - for (int i = 0, s = table.parser.parser().numRecords(); i < s; i++) { - System.out.println(table.get(i)); - } + for (int i = 0, s = table.parser.parser().numRecords(); i < s; i++) table.get(i); + Assert.assertEquals(47, table.getSize(1)); + Assert.assertEquals("gheed", table.getPlace(1, 0)); + Assert.assertEquals("cain1", table.getPlace(1, 1)); + Assert.assertEquals("The Cow King", table.getPlace(1, 45)); + Assert.assertEquals("Corpsefire", table.getPlace(1, 46)); + Assert.assertEquals(59, table.getSize(2)); + Assert.assertEquals("warriv2", table.getPlace(2, 0)); + Assert.assertEquals("skeleton5", table.getPlace(2, 58)); + Assert.assertEquals(39, table.getSize(3)); + Assert.assertEquals("cain3", table.getPlace(3, 0)); + Assert.assertEquals("Maffer Dragonhand", table.getPlace(3, 38)); + Assert.assertEquals(28, table.getSize(4)); + Assert.assertEquals("place_champion", table.getPlace(4, 0)); + Assert.assertEquals("The Feature Creep", table.getPlace(4, 27)); + Assert.assertEquals(56, table.getSize(5)); + Assert.assertEquals("larzuk", table.getPlace(5, 0)); + Assert.assertEquals("place_nothing", table.getPlace(5, 55)); } }