<commit_before>package org.jsuffixarrays;

import java.util.ArrayList;
import java.util.Arrays;

import org.junit.Assert;
import org.junit.Test;

/**
 * Test methods for {@link Traversals}.
 */
public class TraversalsTest
{
    /**
     * Test post-order walking of the virtual suffix tree.
     */
    @Test
    public void preorder()
    {
        final String input = "mississippi$";
        final SuffixData sd = SuffixArrays.createWithLCP(input);

        final String [] expected = {
            "$",
            "i$",
            "ippi$",
            "issippi$",
            "ississippi$",
            "issi",
            "i",
            "mississippi$",
            "pi$",
            "ppi$",
            "p",
            "sippi$",
            "sissippi$",
            "si",
            "ssippi$",
            "ssissippi$",
            "ssi",
            "s",
            "" /* root */
        };

        final ArrayList<String> actual = new ArrayList<String>();

        Traversals.postorder(input.length(), sd.getSuffixArray(), sd.getLCP(),
            new Traversals.IPostOrderVisitor()
            {
                public void visitNode(int start, int length)
                {
                    actual.add(input.subSequence(start, start + length).toString());
                }
            });

        Assert.assertEquals(Arrays.asList(expected), actual);
    }
}<commit_msg>Corrected method name. Added empty input test.<commit_after>package org.jsuffixarrays;

import java.util.ArrayList;
import java.util.Arrays;

import org.junit.Assert;
import org.junit.Test;

/**
 * Test methods for {@link Traversals}.
 */
public class TraversalsTest
{
    /**
     * Test post-order walking of the virtual suffix tree.
     */
    @Test
    public void postorderTest()
    {
        final String input = "mississippi$";
        final SuffixData sd = SuffixArrays.createWithLCP(input);

        final String [] expected = {
            "$",
            "i$",
            "ippi$",
            "issippi$",
            "ississippi$",
            "issi",
            "i",
            "mississippi$",
            "pi$",
            "ppi$",
            "p",
            "sippi$",
            "sissippi$",
            "si",
            "ssippi$",
            "ssissippi$",
            "ssi",
            "s",
            "" /* root */
        };

        final ArrayList<String> actual = new ArrayList<String>();

        Traversals.postorder(input.length(), sd.getSuffixArray(), sd.getLCP(),
            new Traversals.IPostOrderVisitor()
            {
                public void visitNode(int start, int length)
                {
                    actual.add(input.subSequence(start, start + length).toString());
                }
            });

        Assert.assertEquals(Arrays.asList(expected), actual);
    }
    
    /**
     * Border cases for post-order traversal.
     */
    @Test
    public void preorderEmptyInput()
    {
        // Empty input? No root, no nothing.
        final SuffixData sd = SuffixArrays.createWithLCP("");
        Traversals.postorder(0, sd.getSuffixArray(), sd.getLCP(),
            new Traversals.IPostOrderVisitor()
            {
                public void visitNode(int start, int length)
                {
                    Assert.fail();
                }
            });
    }
}
{'fraction_non_alphanumeric': 0.12665066026410565, 'fraction_numerical': 0.00030012004801920766, 'mean_word_length': 1.4707190511489994, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '3740637', 'n_tokens_mistral': 943, 'n_tokens_neox': 913, 'n_words': 197}