Completely changed the structure and switched to Eclipse Plugin.
[Mograsim.git] / net.mograsim.logic.ui.am2900 / test / net / mograsim / logic / ui / am2900 / TestUtil.java
diff --git a/net.mograsim.logic.ui.am2900/test/net/mograsim/logic/ui/am2900/TestUtil.java b/net.mograsim.logic.ui.am2900/test/net/mograsim/logic/ui/am2900/TestUtil.java
new file mode 100644 (file)
index 0000000..08c7982
--- /dev/null
@@ -0,0 +1,22 @@
+package net.mograsim.logic.ui.am2900;
+
+public final class TestUtil
+{
+       private TestUtil()
+       {
+
+       }
+
+       /**
+        * Transforms the last four bits of an int to a string that contains the binary ('1' and '0') representation of the 4 bits
+        */
+       public static String to4bitBin(int x)
+       {
+               StringBuilder sb = new StringBuilder(4);
+               sb.append((x & 0b1000) == 0 ? '0' : '1');
+               sb.append((x & 0b0100) == 0 ? '0' : '1');
+               sb.append((x & 0b0010) == 0 ? '0' : '1');
+               sb.append((x & 0b0001) == 0 ? '0' : '1');
+               return sb.toString();
+       }
+}