test_class.declarator: _minBytes = 3
test_class.modifier: private static final
test_class.original_string: private static final int _minBytes = 3;
test_class.type: int
test_class.var_name: _minBytes
test_class.declarator: _input
test_class.modifier: private
test_class.original_string: private long _input;
test_class.type: long
test_class.var_name: _input
test_class.declarator: _expected
test_class.modifier: private
test_class.original_string: private ByteBuffer _expected;
test_class.type: ByteBuffer
test_class.var_name: _expected
test_class.file: yajsync-core/src/test/java/com/github/perlundq/yajsync/internal/session/IntegerCoderTest.java
test_class.identifier: IntegerCoderTest
test_case.body: @Test
      public void testEncodingCorrectness()
      {
          ByteBuffer actual = IntegerCoder.encodeLong(_input, _minBytes);
          assertEquals(String.format("encode %d -> %s, expected %s (minBytes=%d)",
                                     _input,
                                     Text.byteBufferToString(actual),
                                     Text.byteBufferToString(_expected),
                                     _minBytes),
                       _expected, actual);
      }
test_case.class_method_signature: IntegerCoderTest.testEncodingCorrectness()
test_case.full_signature: @Test public void testEncodingCorrectness()
test_case.identifier: testEncodingCorrectness
test_case.invocations: encodeLong assertEquals format byteBufferToString byteBufferToString
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testEncodingCorrectness()
focal_class.declarator: _int_byte_extra = {
          0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* (00 - 3F)/4 */
          0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* (40 - 7F)/4 */
          1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* (80 - BF)/4 */
          2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 5, 6, /* (C0 - FF)/4 */
      }
focal_class.modifier: private static final
focal_class.original_string: private static final byte[] _int_byte_extra = {
          0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* (00 - 3F)/4 */
          0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* (40 - 7F)/4 */
          1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* (80 - BF)/4 */
          2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 5, 6, /* (C0 - FF)/4 */
      };
focal_class.type: byte[]
focal_class.var_name: _int_byte_extra
focal_class.file: yajsync-core/src/main/java/com/github/perlundq/yajsync/internal/session/IntegerCoder.java
focal_class.identifier: IntegerCoder
focal_class.class_method_signature: IntegerCoder.IntegerCoder()
focal_class.full_signature: private  IntegerCoder()
focal_class.identifier: IntegerCoder
focal_class.modifiers: private
focal_class.parameters: ()
focal_class.signature:  IntegerCoder()
focal_class.class_method_signature: IntegerCoder.encodeLong(long value, int minBytes)
focal_class.full_signature: public static ByteBuffer encodeLong(long value, int minBytes)
focal_class.identifier: encodeLong
focal_class.modifiers: public static
focal_class.parameters: (long value, int minBytes)
focal_class.return: ByteBuffer
focal_class.signature: ByteBuffer encodeLong(long value, int minBytes)
focal_class.class_method_signature: IntegerCoder.decodeLong(Readable src, int minBytes)
focal_class.full_signature: public static long decodeLong(Readable src, int minBytes)
focal_class.identifier: decodeLong
focal_class.modifiers: public static
focal_class.parameters: (Readable src, int minBytes)
focal_class.return: long
focal_class.signature: long decodeLong(Readable src, int minBytes)
focal_method.body: public static ByteBuffer encodeLong(long value, int minBytes)
      {
          assert minBytes >= 1 && minBytes <= 8;
  
          byte[] buf = new byte[9];
          BitOps.putLongAsLittleEndian(buf, 1, value);
  
          int count = buf.length - 1; // int lastNonZeroByteIndex = count;
          while (count > minBytes && buf[count] == 0) {
              count--;
          }
  
          int firstByteValue = 0xFF & (1 << (7 - count + minBytes));
          // 1 <= minBytes <= 8
          // minBytes <= count <= 8
          // max(-count + minBytes) when count equals minBytes
          // min(-count + minBytes) == -8 + 1 = -7
          // 1 << ( 7 - 8 + 1) == 1 << 0 == 1;
          // 1 << ( 7 - 0 ) == 128
          // firstByteValue is a power of 2 in range: 1 <= firstByteValue <= 128
  
          if ((0xFF & buf[count]) >= firstByteValue) {
              buf[0] = (byte) ~ (firstByteValue - 1);
              count++;
          } else if (count > minBytes) {
              buf[0] = (byte) ((~ (firstByteValue * 2 - 1)) | buf[count]);
          } else {
              buf[0] = buf[count];
          }
  
          return ByteBuffer.wrap(buf, 0, count);
      }
focal_method.class_method_signature: IntegerCoder.encodeLong(long value, int minBytes)
focal_method.full_signature: public static ByteBuffer encodeLong(long value, int minBytes)
focal_method.identifier: encodeLong
focal_method.invocations: putLongAsLittleEndian wrap
focal_method.modifiers: public static
focal_method.parameters: (long value, int minBytes)
focal_method.return: ByteBuffer
focal_method.signature: ByteBuffer encodeLong(long value, int minBytes)