aboutsummaryrefslogtreecommitdiff
path: root/java/org/brotli/wrapper/dec/CornerCasesTest.java
blob: ab02f23819f6929566e3d81387c2cae5949e9210 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
/* Copyright 2021 Google Inc. All Rights Reserved.

   Distributed under MIT license.
   See file LICENSE for detail or copy at https://opensource.org/licenses/MIT
*/

package org.brotli.wrapper.dec;

import static org.junit.Assert.assertEquals;

import org.brotli.integration.BrotliJniTestBase;
import org.brotli.wrapper.enc.Encoder;
import java.io.IOException;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;

/** Tests for {@link org.brotli.wrapper.enc.Encoder}. */
@RunWith(JUnit4.class)
public class CornerCasesTest extends BrotliJniTestBase {
  @Test
  public void testPowerOfTwoInput() throws IOException {
    // 24 == max window bits to ensure ring-buffer size is not greater than input.
    int len = 1 << 24;
    byte[] data = new byte[len];
    for (int i = 0; i < len; ++i) {
      data[i] = (byte) Integer.bitCount(i);
    }
    byte[] encoded = Encoder.compress(data);
    byte[] decoded = Decoder.decompress(encoded);
    assertEquals(len, decoded.length);
  }
}