package com.geth1b.coding.skills.lc;

import com.geth1b.coding.ds.TreeNode;
import static org.junit.Assert.assertEquals;
import org.junit.Before;
import org.junit.Test;

/**
 * @author geth1b
 */
public class _124_BinaryTreeMaximumPathSum_Test {
  private _124_BinaryTreeMaximumPathSum solution;
  
  @Before public void setUp() {
    solution = new _124_BinaryTreeMaximumPathSum();
  }
  
  @Test public void maxPathSum() {
    TreeNode root = TreeNode.create("1234567".toCharArray());
    assertEquals(18, solution.maxPathSum(root));
  }
  
  @Test public void maxPathSum_failedCase1() {
    TreeNode root = new TreeNode(-3);
    assertEquals(-3, solution.maxPathSum(root));
  }
  
  @Test public void maxPathSum_failedCase2() {
    TreeNode t1 = new TreeNode(2);
    TreeNode t2 = new TreeNode(-1); 
    t1.left = t2;
    assertEquals(2, solution.maxPathSum(t1));
  }   
}

