MCPcopy Index your code
hub / github.com/questdb/questdb / VectFuzzTest

Class VectFuzzTest

core/src/test/java/io/questdb/test/std/VectFuzzTest.java:65–2088  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

63import static io.questdb.std.Vect.BIN_SEARCH_SCAN_UP;
64
65public class VectFuzzTest {
66 @ClassRule
67 public static final TemporaryFolder temp = new TemporaryFolder();
68 private Rnd rnd = new Rnd();
69
70 @Before
71 public void setUp() {
72 rnd.reset();
73 }
74
75 @Test
76 public void testAggregateBoundary() throws Exception {
77 TestUtils.assertMemoryLeak(() -> {
78 abstract class TestCase {
79 final long sizeBytes;
80
81 TestCase(long sizeBytes) {
82 this.sizeBytes = sizeBytes;
83 }
84
85 abstract void run(long ptr, long count, long countPtr);
86 }
87
88 final int nMax = 1024;
89 final TestCase[] testCases = new TestCase[]{
90 new TestCase(Short.BYTES) {
91 @Override
92 void run(long ptr, long count, long countPtr) {
93 if (count == 0) {
94 Assert.assertEquals("short sum, count: 0", Numbers.LONG_NULL, Vect.sumShort(ptr, 0));
95 Assert.assertEquals("short min, count: 0", Numbers.INT_NULL, Vect.minShort(ptr, 0));
96 Assert.assertEquals("short max, count: 0", Numbers.INT_NULL, Vect.maxShort(ptr, 0));
97 } else {
98 Assert.assertEquals("short sum, count: " + count, 0, Vect.sumShort(ptr, count));
99 Assert.assertEquals("short min, count: " + count, 0, Vect.minShort(ptr, count));
100 Assert.assertEquals("short max, count: " + count, 0, Vect.maxShort(ptr, count));
101 }
102 }
103 },
104 new TestCase(Integer.BYTES) {
105 @Override
106 void run(long ptr, long count, long countPtr) {
107 if (count == 0) {
108 Assert.assertEquals("int sum, count: 0", Numbers.LONG_NULL, Vect.sumInt(ptr, 0));
109 Assert.assertEquals("int sum acc, count: 0", Double.NaN, Vect.sumIntAcc(ptr, 0, countPtr), 0.001);
110 Assert.assertEquals("int min, count: 0", Numbers.INT_NULL, Vect.minInt(ptr, 0));
111 Assert.assertEquals("int max, count: 0", Numbers.INT_NULL, Vect.maxInt(ptr, 0));
112 Assert.assertEquals("int count, count: 0", 0, Vect.countInt(ptr, 0));
113 } else {
114 Assert.assertEquals("int sum, count: " + count, 0, Vect.sumInt(ptr, count));
115 Assert.assertEquals("int sum acc, count: " + count, 0, Vect.sumIntAcc(ptr, count, countPtr), 0.001);
116 Assert.assertEquals("int min, count: " + count, 0, Vect.minInt(ptr, count));
117 Assert.assertEquals("int max, count: " + count, 0, Vect.maxInt(ptr, count));
118 Assert.assertEquals("int count, count: " + count, count, Vect.countInt(ptr, count));
119 }
120 }
121 },
122 new TestCase(Long.BYTES) {

Callers

nothing calls this directly

Calls 2

initMethod · 0.95
initMethod · 0.95

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…