<commit_before>/*
 * Java Genetic Algorithm Library (@__identifier__@).
 * Copyright (c) @__year__@ <NAME>
 *
 * 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.
 *
 * Author:
 *    <NAME> (<EMAIL>)
 */
package io.jenetics.ext.util;

import org.testng.Assert;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;

import io.jenetics.ext.util.TreeRewriter.Matcher;

/**
 * @author <a href="mailto:<EMAIL>"><NAME></a>
 */
public class TreeValueMatcherTest {

	@Test(dataProvider = "subTreeMatches")
	public void subTrees(
		final String patternString,
		final String treeString,
		final boolean matches
	) {
		final Tree<String, ?> pattern = TreeNode.parse(patternString);
		final Matcher<Integer> matcher = TreeValueMatcher.of(pattern, Integer::parseInt);

		final Tree<Integer, ?> tree = TreeNode.parse(treeString, Integer::parseInt);
		Assert.assertEquals(matcher.matches(tree), matches);
	}

	@DataProvider(name = "subTreeMatches")
	public Object[][] subTreeMatches() {
		return new Object[][] {
			{"0(1,2)", "0(1,2)", true}
		};
	}

}<commit_msg>#386: Add some matching tests.<commit_after>/*
 * Java Genetic Algorithm Library (@__identifier__@).
 * Copyright (c) @__year__@ <NAME>
 *
 * 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.
 *
 * Author:
 *    <NAME> (<EMAIL>)
 */
package io.jenetics.ext.util;

import org.testng.Assert;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;

import io.jenetics.ext.util.TreeRewriter.Matcher;

/**
 * @author <a href="mailto:<EMAIL>"><NAME></a>
 */
public class TreeValueMatcherTest {

	@Test(dataProvider = "subTreeMatches")
	public void subTrees(
		final String patternString,
		final String treeString,
		final boolean matches
	) {
		final Tree<String, ?> pattern = TreeNode.parse(patternString);
		final Matcher<Integer> matcher = TreeValueMatcher.of(pattern, Integer::parseInt);

		final Tree<Integer, ?> tree = TreeNode.parse(treeString, Integer::parseInt);
		Assert.assertEquals(matcher.matches(tree), matches);
	}

	@DataProvider(name = "subTreeMatches")
	public Object[][] subTreeMatches() {
		return new Object[][] {
			{"0(1,2)", "0(1,2)", true},
			{"0(1,2,X)", "0(1,2)", true},
			{"0(3,2,X)", "0(1,2)", false}
		};
	}

}
{'fraction_non_alphanumeric': 0.13093037584719655, 'fraction_numerical': 0.010782501540357363, 'mean_word_length': 4.503389830508475, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '1465594', 'n_tokens_mistral': 1023, 'n_tokens_neox': 981, 'n_words': 306}