1 // Copyright (c) 2011-present, Facebook, Inc.  All rights reserved.
2 //  This source code is licensed under both the GPLv2 (found in the
3 //  COPYING file in the root directory) and Apache 2.0 License
4 //  (found in the LICENSE.Apache file in the root directory).
5 
6 package org.rocksdb;
7 
8 import org.junit.ClassRule;
9 import org.junit.Test;
10 
11 import static org.assertj.core.api.Assertions.assertThat;
12 
13 public class ComparatorOptionsTest {
14 
15   @ClassRule
16   public static final RocksNativeLibraryResource ROCKS_NATIVE_LIBRARY_RESOURCE =
17       new RocksNativeLibraryResource();
18 
19   @Test
reusedSynchronisationType()20   public void reusedSynchronisationType() {
21     try(final ComparatorOptions copt = new ComparatorOptions()) {
22 
23       copt.setReusedSynchronisationType(ReusedSynchronisationType.MUTEX);
24       assertThat(copt.reusedSynchronisationType())
25           .isEqualTo(ReusedSynchronisationType.MUTEX);
26 
27       copt.setReusedSynchronisationType(ReusedSynchronisationType.ADAPTIVE_MUTEX);
28       assertThat(copt.reusedSynchronisationType())
29           .isEqualTo(ReusedSynchronisationType.ADAPTIVE_MUTEX);
30 
31       copt.setReusedSynchronisationType(ReusedSynchronisationType.THREAD_LOCAL);
32       assertThat(copt.reusedSynchronisationType())
33           .isEqualTo(ReusedSynchronisationType.THREAD_LOCAL);
34     }
35   }
36 
37   @Test
useDirectBuffer()38   public void useDirectBuffer() {
39     try(final ComparatorOptions copt = new ComparatorOptions()) {
40       copt.setUseDirectBuffer(true);
41       assertThat(copt.useDirectBuffer()).isTrue();
42 
43       copt.setUseDirectBuffer(false);
44       assertThat(copt.useDirectBuffer()).isFalse();
45     }
46   }
47 
48   @Test
maxReusedBufferSize()49   public void maxReusedBufferSize() {
50     try(final ComparatorOptions copt = new ComparatorOptions()) {
51       copt.setMaxReusedBufferSize(12345);
52       assertThat(copt.maxReusedBufferSize()).isEqualTo(12345);
53 
54       copt.setMaxReusedBufferSize(-1);
55       assertThat(copt.maxReusedBufferSize()).isEqualTo(-1);
56     }
57   }
58 }
59