// Path: src/main/java/org/lmdbjava/ByteArrayProxy.java
// public static final BufferProxy<byte[]> PROXY_BA = new ByteArrayProxy();
// 
// Path: src/main/java/org/lmdbjava/ByteBufferProxy.java
// public static final BufferProxy<ByteBuffer> PROXY_OPTIMAL;
// 
// Path: src/main/java/org/lmdbjava/DirectBufferProxy.java
// public static final BufferProxy<DirectBuffer> PROXY_DB
//     = new DirectBufferProxy();


import static io.netty.buffer.PooledByteBufAllocator.DEFAULT;
import static java.nio.charset.StandardCharsets.US_ASCII;
import static org.hamcrest.core.Is.is;
import static org.junit.Assert.assertThat;
import static org.lmdbjava.ByteArrayProxy.PROXY_BA;
import static org.lmdbjava.ByteBufferProxy.PROXY_OPTIMAL;
import static org.lmdbjava.ComparatorTest.ComparatorResult.EQUAL_TO;
import static org.lmdbjava.ComparatorTest.ComparatorResult.GREATER_THAN;
import static org.lmdbjava.ComparatorTest.ComparatorResult.LESS_THAN;
import static org.lmdbjava.ComparatorTest.ComparatorResult.get;
import static org.lmdbjava.DirectBufferProxy.PROXY_DB;
import java.nio.ByteBuffer;
import java.util.Arrays;
import java.util.Comparator;
import com.google.common.primitives.SignedBytes;
import com.google.common.primitives.UnsignedBytes;
import io.netty.buffer.ByteBuf;
import org.agrona.DirectBuffer;
import org.agrona.concurrent.UnsafeBuffer;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.junit.runners.Parameterized.Parameter;
import org.junit.runners.Parameterized.Parameters;
/*-
 * #%L
 * LmdbJava
 * %%
 * Copyright (C) 2016 - 2021 The LmdbJava Open Source Project
 * %%
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *      http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * #L%
 */

package org.lmdbjava;




/**
 * Tests comparator functions are consistent across buffers.
 */
@RunWith(Parameterized.class)
public final class ComparatorTest {

  // H = 1 (high), L = 0 (low), X = byte not set in buffer
  private static final byte[] HL = buffer(1, 0);
  private static final byte[] HLLLLLLL = buffer(1, 0, 0, 0, 0, 0, 0, 0);
  private static final byte[] HLLLLLLX = buffer(1, 0, 0, 0, 0, 0, 0);
  private static final byte[] HX = buffer(1);
  private static final byte[] LH = buffer(0, 1);
  private static final byte[] LHLLLLLL = buffer(0, 1, 0, 0, 0, 0, 0, 0);
  private static final byte[] LL = buffer(0, 0);
  private static final byte[] LLLLLLLL = buffer(0, 0, 0, 0, 0, 0, 0, 0);
  private static final byte[] LLLLLLLX = buffer(0, 0, 0, 0, 0, 0, 0);
  private static final byte[] LX = buffer(0);
  private static final byte[] XX = buffer();
  /**
   * Injected by {@link #data()} with appropriate runner.
   */
  @Parameter
  public ComparatorRunner comparator;

  @Parameters(name = "{index}: comparable: {0}")
  public static Object[] data() {
// Path: src/main/java/org/lmdbjava/ByteArrayProxy.java
// public static final BufferProxy<byte[]> PROXY_BA = new ByteArrayProxy();
// 
// Path: src/main/java/org/lmdbjava/ByteBufferProxy.java
// public static final BufferProxy<ByteBuffer> PROXY_OPTIMAL;
// 
// Path: src/main/java/org/lmdbjava/DirectBufferProxy.java
// public static final BufferProxy<DirectBuffer> PROXY_DB
//     = new DirectBufferProxy();


// Path: src/test/java/org/lmdbjava/ComparatorTest.java
import static io.netty.buffer.PooledByteBufAllocator.DEFAULT;
import static java.nio.charset.StandardCharsets.US_ASCII;
import static org.hamcrest.core.Is.is;
import static org.junit.Assert.assertThat;
import static org.lmdbjava.ByteArrayProxy.PROXY_BA;
import static org.lmdbjava.ByteBufferProxy.PROXY_OPTIMAL;
import static org.lmdbjava.ComparatorTest.ComparatorResult.EQUAL_TO;
import static org.lmdbjava.ComparatorTest.ComparatorResult.GREATER_THAN;
import static org.lmdbjava.ComparatorTest.ComparatorResult.LESS_THAN;
import static org.lmdbjava.ComparatorTest.ComparatorResult.get;
import static org.lmdbjava.DirectBufferProxy.PROXY_DB;
import java.nio.ByteBuffer;
import java.util.Arrays;
import java.util.Comparator;
import com.google.common.primitives.SignedBytes;
import com.google.common.primitives.UnsignedBytes;
import io.netty.buffer.ByteBuf;
import org.agrona.DirectBuffer;
import org.agrona.concurrent.UnsafeBuffer;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.junit.runners.Parameterized.Parameter;
import org.junit.runners.Parameterized.Parameters;

/*-
 * #%L
 * LmdbJava
 * %%
 * Copyright (C) 2016 - 2021 The LmdbJava Open Source Project
 * %%
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *      http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * #L%
 */

package org.lmdbjava;




/**
 * Tests comparator functions are consistent across buffers.
 */
@RunWith(Parameterized.class)
public final class ComparatorTest {

  // H = 1 (high), L = 0 (low), X = byte not set in buffer
  private static final byte[] HL = buffer(1, 0);
  private static final byte[] HLLLLLLL = buffer(1, 0, 0, 0, 0, 0, 0, 0);
  private static final byte[] HLLLLLLX = buffer(1, 0, 0, 0, 0, 0, 0);
  private static final byte[] HX = buffer(1);
  private static final byte[] LH = buffer(0, 1);
  private static final byte[] LHLLLLLL = buffer(0, 1, 0, 0, 0, 0, 0, 0);
  private static final byte[] LL = buffer(0, 0);
  private static final byte[] LLLLLLLL = buffer(0, 0, 0, 0, 0, 0, 0, 0);
  private static final byte[] LLLLLLLX = buffer(0, 0, 0, 0, 0, 0, 0);
  private static final byte[] LX = buffer(0);
  private static final byte[] XX = buffer();
  /**
   * Injected by {@link #data()} with appropriate runner.
   */
  @Parameter
  public ComparatorRunner comparator;

  @Parameters(name = "{index}: comparable: {0}")
  public static Object[] data() {
    final ComparatorRunner string = new StringRunner();