X-Git-Url: https://mograsim.net/gitweb/?a=blobdiff_plain;ds=sidebyside;f=net.mograsim.logic.ui.am2900%2Ftest%2Fnet%2Fmograsim%2Flogic%2Fui%2Fam2900%2FTestUtil.java;fp=net.mograsim.logic.ui.am2900%2Ftest%2Fnet%2Fmograsim%2Flogic%2Fui%2Fam2900%2FTestUtil.java;h=08c7982e7276e3677b7c1e474b4b86ecbaa0a0af;hb=f14ea37d69488dd51518a36413af7176916b8bd7;hp=0000000000000000000000000000000000000000;hpb=a84700145147c263ad6692c99117a7cf37832378;p=Mograsim.git 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 index 00000000..08c7982e --- /dev/null +++ b/net.mograsim.logic.ui.am2900/test/net/mograsim/logic/ui/am2900/TestUtil.java @@ -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(); + } +}