From 8871e01861710860bbba8aa688d32938e3c58180 Mon Sep 17 00:00:00 2001 From: William M Date: Wed, 5 Jun 2024 23:03:43 +0800 Subject: [PATCH] [nodeploy] Clean up tests --- src/test/java/com/cominatyou/RankTest.java | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/test/java/com/cominatyou/RankTest.java b/src/test/java/com/cominatyou/RankTest.java index 8fcca6f..aa63c75 100644 --- a/src/test/java/com/cominatyou/RankTest.java +++ b/src/test/java/com/cominatyou/RankTest.java @@ -12,15 +12,16 @@ public class RankTest { private static final int[] rankLevels = RankUtil.getRanklevels(); + private static final int TOTAL_RANK_LEVEL_COUNT = 26; @Test public void ensureCorrectAmountOfRankLevels() { - assertEquals(26, rankLevels.length); + assertEquals(TOTAL_RANK_LEVEL_COUNT, rankLevels.length); } @Test public void ensureUniqueRankRoleIDs() { - final ArrayList seenIDs = new ArrayList<>(26); + final ArrayList seenIDs = new ArrayList<>(TOTAL_RANK_LEVEL_COUNT); for (final int i : rankLevels) { final Rank rank = RankUtil.getRankFromLevel(i); if (seenIDs.contains(rank.getId())) { @@ -36,7 +37,7 @@ public void ensureUniqueRankRoleIDs() { public void ensureCorrectRankRoleIdFormat() { for (final int i : rankLevels) { final Rank rank = RankUtil.getRankFromLevel(i); - if (!String.valueOf(rank.getId()).matches("^[0-9]{17,19}$")) { + if (!String.valueOf(rank.getId()).matches("^[0-9]{17,}$")) { fail(String.format("Level %d: ID %d is not a Discord snowflake!", i, rank.getId())); } } @@ -54,14 +55,14 @@ public void ensureCorrectRankLevels() { public void ensureSortedRankLevels() { for (int i = 0; i < rankLevels.length - 1; i++) { if (rankLevels[i] > rankLevels[i + 1]) { - fail(String.format("Level %d: next level is %d, which is less a lower level", rankLevels[i], rankLevels[i + 1])); + fail(String.format("Level %d: next level is %d, which is a lower level", rankLevels[i], rankLevels[i + 1])); } } } @Test public void ensureUniqueRankNames() { - final ArrayList seenNames = new ArrayList<>(26); + final ArrayList seenNames = new ArrayList<>(TOTAL_RANK_LEVEL_COUNT); for (final int i : rankLevels) { final Rank rank = RankUtil.getRankFromLevel(i); if (seenNames.contains(rank.getName())) {