<commit_before>/*
 * File:                CategorizationTreeNodeTest.java
 * Authors:             <NAME>
 * Company:             Sandia National Laboratories
 * Project:             Cognitive Foundry
 *
 * Copyright November 16, 2007, Sandia Corporation.  Under the terms of Contract
 * DE-AC04-94AL85000, there is a non-exclusive license for use of this work by
 * or on behalf of the U.S. Government. Export of this program may require a
 * license from the United States Government. See CopyrightHistory.txt for
 * complete details.
 *
 *
 */

package gov.sandia.cognition.learning.algorithm.tree;

import gov.sandia.cognition.learning.function.categorization.VectorElementThresholdCategorizer;
import junit.framework.*;
import gov.sandia.cognition.math.matrix.mtj.Vector3;

/**
 * This class implements JUnit tests for the following classes:
 *
 *     CategorizationTreeNode
 *
 * @author <NAME>
 * @since  2.0
 */
public class CategorizationTreeNodeTest
    extends TestCase
{
    public CategorizationTreeNodeTest(
        String testName)
    {
        super(testName);
    }
    
    public void testConstructors()
    {
        DecisionTreeNode<Vector3, String> parent = null;
        CategorizationTreeNode<Vector3, String, Boolean> instance = 
            new CategorizationTreeNode<Vector3, String, Boolean>();
        assertSame(parent, instance.getParent());
        assertNull(instance.getOutputCategory());
        assertNull(instance.getDecider());
        assertNull(instance.getIncomingValue());
        
        String outputCategory = "a";
        instance = new CategorizationTreeNode<Vector3, String, Boolean>(parent,
            outputCategory);
        assertSame(parent, instance.getParent());
        assertSame(outputCategory, instance.getOutputCategory());
        assertNull(instance.getDecider());
        assertNull(instance.getIncomingValue());
        
        Object incomingValue = Math.random();
        instance = new CategorizationTreeNode<Vector3, String, Boolean>(parent,
            outputCategory, incomingValue);
        assertSame(parent, instance.getParent());
        assertSame(outputCategory, instance.getOutputCategory());
        assertNull(instance.getDecider());
        assertSame(incomingValue, instance.getIncomingValue());
        
        VectorElementThresholdCategorizer decider = 
            new VectorElementThresholdCategorizer(4, Math.random());
        instance = new CategorizationTreeNode<Vector3, String, Boolean>(parent,
            decider, outputCategory, incomingValue);
        assertSame(parent, instance.getParent());
        assertSame(outputCategory, instance.getOutputCategory());
        assertSame(decider, instance.getDecider());
        assertSame(incomingValue, instance.getIncomingValue());
    }

    /**
     * Test of clone method, of class gov.sandia.cognition.learning.algorithm.tree.CategorizationTreeNode.
     */
    public void testClone()
    {
        String outputCategory = "a";
        Object incomingValue = Math.random();
        VectorElementThresholdCategorizer decider = 
            new VectorElementThresholdCategorizer(4, Math.random());
        
        CategorizationTreeNode<Vector3, String, Boolean> instance = 
            new CategorizationTreeNode<Vector3, String, Boolean>(null,
                decider, outputCategory, incomingValue);
        
        CategorizationTreeNode<Vector3, String, Boolean> clone = instance.clone();
        assertSame(outputCategory, clone.getOutputCategory());
        assertSame(decider, clone.getDecider());<commit_msg>Fixed failing unit test due to clone fix.<commit_after>/*
 * File:                CategorizationTreeNodeTest.java
 * Authors:             <NAME>
 * Company:             Sandia National Laboratories
 * Project:             Cognitive Foundry
 *
 * Copyright November 16, 2007, Sandia Corporation.  Under the terms of Contract
 * DE-AC04-94AL85000, there is a non-exclusive license for use of this work by
 * or on behalf of the U.S. Government. Export of this program may require a
 * license from the United States Government. See CopyrightHistory.txt for
 * complete details.
 *
 *
 */

package gov.sandia.cognition.learning.algorithm.tree;

import gov.sandia.cognition.learning.function.categorization.VectorElementThresholdCategorizer;
import junit.framework.*;
import gov.sandia.cognition.math.matrix.mtj.Vector3;

/**
 * This class implements JUnit tests for the following classes:
 *
 *     CategorizationTreeNode
 *
 * @author <NAME>
 * @since  2.0
 */
public class CategorizationTreeNodeTest
    extends TestCase
{
    public CategorizationTreeNodeTest(
        String testName)
    {
        super(testName);
    }
    
    public void testConstructors()
    {
        DecisionTreeNode<Vector3, String> parent = null;
        CategorizationTreeNode<Vector3, String, Boolean> instance = 
            new CategorizationTreeNode<Vector3, String, Boolean>();
        assertSame(parent, instance.getParent());
        assertNull(instance.getOutputCategory());
        assertNull(instance.getDecider());
        assertNull(instance.getIncomingValue());
        
        String outputCategory = "a";
        instance = new CategorizationTreeNode<Vector3, String, Boolean>(parent,
            outputCategory);
        assertSame(parent, instance.getParent());
        assertSame(outputCategory, instance.getOutputCategory());
        assertNull(instance.getDecider());
        assertNull(instance.getIncomingValue());
        
        Object incomingValue = Math.random();
        instance = new CategorizationTreeNode<Vector3, String, Boolean>(parent,
            outputCategory, incomingValue);
        assertSame(parent, instance.getParent());
        assertSame(outputCategory, instance.getOutputCategory());
        assertNull(instance.getDecider());
        assertSame(incomingValue, instance.getIncomingValue());
        
        VectorElementThresholdCategorizer decider = 
            new VectorElementThresholdCategorizer(4, Math.random());
        instance = new CategorizationTreeNode<Vector3, String, Boolean>(parent,
            decider, outputCategory, incomingValue);
        assertSame(parent, instance.getParent());
        assertSame(outputCategory, instance.getOutputCategory());
        assertSame(decider, instance.getDecider());
        assertSame(incomingValue, instance.getIncomingValue());
    }

    /**
     * Test of clone method, of class gov.sandia.cognition.learning.algorithm.tree.CategorizationTreeNode.
     */
    public void testClone()
    {
        String outputCategory = "a";
        Object incomingValue = Math.random();
        VectorElementThresholdCategorizer decider = 
            new VectorElementThresholdCategorizer(4, Math.random());
        
        CategorizationTreeNode<Vector3, String, Boolean> instance = 
            new CategorizationTreeNode<Vector3, String, Boolean>(null,
                decider, outputCategory, incomingValue);
        
        CategorizationTreeNode<Vector3, String, Boolean> clone = instance.clone();
        assertSame(outputCategory, clone.getOutputCategory());
        assertEquals(decider.toString(), clone.getDecider().toString());
        assertNotSame(decider, clone.getDecider());
{'fraction_non_alphanumeric': 0.09425096738529574, 'fraction_numerical': 0.008015478164731896, 'mean_word_length': 3.1354285714285712, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 25, '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': '382414', 'n_tokens_mistral': 1886, 'n_tokens_neox': 1867, 'n_words': 420}