<commit_before>package org.mwg.core.chunk;

import org.junit.Assert;
import org.junit.Test;
import org.mwg.Constants;
import org.mwg.chunk.ChunkSpace;
import org.mwg.chunk.ChunkType;
import org.mwg.chunk.TimeTreeChunk;
import org.mwg.chunk.TreeWalker;
import org.mwg.plugin.MemoryFactory;
import org.mwg.struct.Buffer;

public abstract class AbstractTimeTreeTest {

    private MemoryFactory factory;

    public AbstractTimeTreeTest(MemoryFactory factory) {
        this.factory = factory;
    }

    @Test
    public void nextTest() {
        ChunkSpace space = factory.newSpace(100, null);
        TimeTreeChunk tree = (TimeTreeChunk) space.createAndMark(ChunkType.TIME_TREE_CHUNK, 0, 0, 0);
        for (long i = 0; i <= 6; i++) {
            tree.insert(i);
        }
        tree.insert(8L);
        tree.insert(10L);
        tree.insert(11L);
        tree.insert(13L);

        Assert.assertEquals(tree.next(-1), Constants.NULL_LONG);
        Assert.assertEquals(tree.next(0), 1L);
        Assert.assertEquals(tree.next(1), 2L);
        Assert.assertEquals(tree.next(7), 8L);
        Assert.assertEquals(tree.next(8), 10L);
        Assert.assertEquals(tree.next(9), 10L);
        Assert.assertEquals(tree.next(10), 11L);
        Assert.assertEquals(tree.next(13), Constants.NULL_LONG);
        Assert.assertEquals(tree.next(14), Constants.NULL_LONG);

        space.free(tree);
        space.freeAll();
    }

    @Test
    public void previousOrEqualsTest() {
        ChunkSpace space = factory.newSpace(100, null);<commit_msg>add test for previous method for heap and offheap<commit_after>package org.mwg.core.chunk;

import org.junit.Assert;
import org.junit.Test;
import org.mwg.Constants;
import org.mwg.chunk.ChunkSpace;
import org.mwg.chunk.ChunkType;
import org.mwg.chunk.TimeTreeChunk;
import org.mwg.chunk.TreeWalker;
import org.mwg.plugin.MemoryFactory;
import org.mwg.struct.Buffer;

public abstract class AbstractTimeTreeTest {

    private MemoryFactory factory;

    public AbstractTimeTreeTest(MemoryFactory factory) {
        this.factory = factory;
    }

    @Test
    public void nextTest() {
        ChunkSpace space = factory.newSpace(100, null);
        TimeTreeChunk tree = (TimeTreeChunk) space.createAndMark(ChunkType.TIME_TREE_CHUNK, 0, 0, 0);
        for (long i = 0; i <= 6; i++) {
            tree.insert(i);
        }
        tree.insert(8L);
        tree.insert(10L);
        tree.insert(11L);
        tree.insert(13L);

        Assert.assertEquals(tree.previous(-1), Constants.NULL_LONG);
        Assert.assertEquals(tree.previous(0), Constants.NULL_LONG);
        Assert.assertEquals(tree.previous(1), 0L);
        Assert.assertEquals(tree.previous(7), 6L);
        Assert.assertEquals(tree.previous(8), 6L);
        Assert.assertEquals(tree.previous(9), 8L);
        Assert.assertEquals(tree.previous(10), 8L);
        Assert.assertEquals(tree.previous(13), 11L);
        Assert.assertEquals(tree.previous(14), 13L);

        space.free(tree);
        space.freeAll();
    }

    @Test
    public void previousOrEqualsTest() {
        ChunkSpace space = factory.newSpace(100, null);
{'fraction_non_alphanumeric': 0.12516005121638923, 'fraction_numerical': 0.02496798975672215, 'mean_word_length': 3.0584415584415585, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2403332', 'n_tokens_mistral': 1038, 'n_tokens_neox': 959, 'n_words': 181}