From 321e2246fcce15d7d2243b5ce52243bb1fdaee2a Mon Sep 17 00:00:00 2001 From: TomyLobo Date: Fri, 24 May 2013 02:03:08 +0300 Subject: [PATCH] Added some comments to BlockDataTest.testCycle. --- .../com/sk89q/worldedit/blocks/BlockDataTest.java | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/test/java/com/sk89q/worldedit/blocks/BlockDataTest.java b/src/test/java/com/sk89q/worldedit/blocks/BlockDataTest.java index 73162d70f..c29c996f3 100644 --- a/src/test/java/com/sk89q/worldedit/blocks/BlockDataTest.java +++ b/src/test/java/com/sk89q/worldedit/blocks/BlockDataTest.java @@ -73,8 +73,9 @@ public class BlockDataTest { @Test public void testCycle() { - // Test monotony + // Test monotony and continuity for (int type = 0; type < 256; ++type) { + // Cloth isn't monotonous, and thus excluded. if (type == BlockID.CLOTH) continue; for (int data = 0; data < 16; ++data) { @@ -82,10 +83,12 @@ public class BlockDataTest { final int cycled = BlockData.cycle(type, data, 1); + // If the cycle goes back (including -1), everything is ok. if (cycled <= data) { continue; } + // If there's a gap in the cycle, there's a problem. assertEquals(message, data + 1, cycled); } } @@ -98,6 +101,7 @@ public class BlockDataTest { } private static void testCycle(final int increment) { + // Iterate each block type and data value that wasn't part of a cycle yet. for (int type = 0; type < 256; ++type) { @SuppressWarnings("unchecked") final TreeSet datas = (TreeSet) datasTemplate.clone(); @@ -108,12 +112,21 @@ public class BlockDataTest { boolean first = true; while (true) { current = BlockData.cycle(type, current, increment); + + // If the cycle immediately goes to -1, everything is ok. if (first && current == -1) break; + first = false; message += "->" + current; + + // If the cycle goes off limits (including -1), there's a problem. assertTrue(message, current >= 0); assertTrue(message, current < 16); + + // The cycle completes, everything is ok. if (current == start) break; + + // Mark the current element as walked. assertTrue(message, datas.remove(current)); } }