ColorUnpacker { static byte[] getOrderedRgbBytes(Mode ledMode, byte r, byte g, byte b) { switch (ledMode) { case RBG: return new byte[]{r, b, g}; case BGR: return new byte[]{b, g, r}; case BRG: return new byte[]{b, r, g}; case GRB: return new byte[]{g, r, b}; case GBR: return new byte[]{g, b, r}; default: throw new IllegalArgumentException(ledMode.name() + " is an unknown " + Mode.class.getSimpleName()); } } ColorUnpacker(Mode ledMode);   }
@Test public void orderedBytesWhenModeIsGBR() { Ws2801.Mode mode = Ws2801.Mode.GBR; byte[] result = ColorUnpacker.getOrderedRgbBytes(mode, R, G, B); assertBytesOrder(result, G, B, R); }
@Test public void orderedBytesWhenModeIsRBG() { Ws2801.Mode mode = Ws2801.Mode.RBG; byte[] result = ColorUnpacker.getOrderedRgbBytes(mode, R, G, B); assertBytesOrder(result, R, B, G); }
@Test public void orderedBytesWhenModeIsBGR() { Ws2801.Mode mode = Ws2801.Mode.BGR; byte[] result = ColorUnpacker.getOrderedRgbBytes(mode, R, G, B); assertBytesOrder(result, B, G, R); }
@Test public void orderedBytesWhenModeIsBRG() { Ws2801.Mode mode = Ws2801.Mode.BRG; byte[] result = ColorUnpacker.getOrderedRgbBytes(mode, R, G, B); assertBytesOrder(result, B, R, G); }
@Test public void orderedBytesWhenModeIsGRB() { Ws2801.Mode mode = Ws2801.Mode.GRB; byte[] result = ColorUnpacker.getOrderedRgbBytes(mode, R, G, B); assertBytesOrder(result, G, R, B); }