Exemplo n.º 1
0
  @Test
  public void compress_shouldReturnACompressedVersionOfTheTwoCommands() {
    PclCommand command =
        new PclCommandBuilder()
            .p(LOWEST_PARAMETERIZED_BYTE)
            .g(LOWEST_GROUP_BYTE)
            .v("1")
            .t(LOWEST_TERMINATION_BYTE)
            .toCommand();

    ParameterizedCommand expectedCompressedCommand =
        new ParameterizedCommand(
            new byte[] {
              ESCAPE,
              LOWEST_PARAMETERIZED_BYTE,
              LOWEST_GROUP_BYTE,
              '1',
              LOWEST_PARAMETER_BYTE,
              '1',
              LOWEST_TERMINATION_BYTE
            });

    PclCommand compressedCommand = compressor.compress(command, command);

    assertNotNull(compressedCommand);
    assertEquals(expectedCompressedCommand, compressedCommand);
  }
Exemplo n.º 2
0
  @Test
  public void canBeCompressed_bothCommandAreParameterizedCommandButWithDifferentGroups() {
    PclCommandBuilder builder =
        new PclCommandBuilder().p(LOWEST_PARAMETERIZED_BYTE).v("1").t(LOWEST_TERMINATION_BYTE);

    PclCommand command = builder.copy().g(LOWEST_GROUP_BYTE).toCommand();
    PclCommand otherCommand = builder.copy().g(HIGHEST_GROUP_BYTE).toCommand();

    assertFalse(compressor.canBeCompressed(command, otherCommand));
  }
Exemplo n.º 3
0
  @Test(expected = IllegalArgumentException.class)
  public void compress_shouldBlowUpIfTheCommandsCanNotBeCompressed() {
    PclCommandBuilder builder =
        new PclCommandBuilder().p(LOWEST_PARAMETERIZED_BYTE).v("1").t(LOWEST_TERMINATION_BYTE);

    PclCommand command = builder.copy().g(LOWEST_GROUP_BYTE).toCommand();
    PclCommand otherCommand = builder.copy().g(HIGHEST_GROUP_BYTE).toCommand();

    compressor.compress(command, otherCommand);
  }
Exemplo n.º 4
0
 @Test
 public void
     canBeCompressed_bothCommandAreParameterizedCommandWithMatchingParameterizedAndGroupBytes() {
   PclCommand command =
       new PclCommandBuilder()
           .p(LOWEST_PARAMETERIZED_BYTE)
           .g(LOWEST_GROUP_BYTE)
           .v("1")
           .t(LOWEST_TERMINATION_BYTE)
           .toCommand();
   assertTrue(compressor.canBeCompressed(command, command));
 }
Exemplo n.º 5
0
  @Test
  public void canBeCompressed_bothCommandAreParameterizedButFirstCommandHasBinaryData() {
    PclCommandBuilder builder =
        new PclCommandBuilder()
            .p(LOWEST_PARAMETERIZED_BYTE)
            .g(LOWEST_GROUP_BYTE)
            .v("1")
            .t(LOWEST_TERMINATION_BYTE);

    PclCommand command = builder.copy().d("12").toCommand();
    PclCommand otherCommand = builder.toCommand();

    assertFalse(compressor.canBeCompressed(command, otherCommand));
  }
Exemplo n.º 6
0
 @Test
 public void canBeCompressed_secondCommandIsATextCommand() {
   assertFalse(
       compressor.canBeCompressed(
           new ParameterizedCommand(new byte[3]), new TextCommand("X".getBytes())));
 }
Exemplo n.º 7
0
 @Test
 public void canBeCompressed_firstCommandIsATwoByteCommandAndCanNotBeCompressed() {
   assertFalse(
       compressor.canBeCompressed(
           new TwoByteCommand(new byte[2]), new ParameterizedCommand(new byte[3])));
 }
Exemplo n.º 8
0
 @Test
 public void canBeCompressed_firstCommandIsNullAndCanNotBeCompressed() {
   assertFalse(compressor.canBeCompressed(null, new ParameterizedCommand(new byte[3])));
 }