1 package jp.sourceforge.stigmata.birthmarks.osb;
\r
3 import org.junit.Assert;
\r
4 import org.junit.Before;
\r
5 import org.junit.Test;
\r
7 public class LCSCalculatorTest{
\r
8 private LCSCalculator<String> calculator;
\r
11 public void setUp(){
\r
12 calculator = new LCSCalculator<String>();
\r
16 public void testBasic(){
\r
17 String[] elementA = new String[] { "load", "load", "add", "store", };
\r
18 String[] elementB = new String[] { "load", "load", "mul", "load", "sub", "store", };
\r
20 Assert.assertEquals(3, calculator.calculate(elementA, elementB));
\r
21 Assert.assertEquals(3, calculator.calculate(elementB, elementA));
\r
25 public void testNullElement(){
\r
26 String[] elementA = new String[] { "load", "load", "add", null, };
\r
27 String[] elementB = new String[] { "load", "load", "mul", "load", "sub", null, };
\r
29 Assert.assertEquals(3, calculator.calculate(elementA, elementB));
\r
33 public void testZeroLengthArray(){
\r
34 String[] elementB = new String[] { "load", "load", "mul", "load", "sub", "store", };
\r
36 Assert.assertEquals(0, calculator.calculate(new String[0], elementB));
\r
39 @Test(expected=NullPointerException.class)
\r
40 public void testNullCheck1(){
\r
41 String[] elementB = new String[] { "load", "load", "mul", "load", "sub", "store", };
\r
43 calculator.calculate(null, elementB);
\r
46 @Test(expected=NullPointerException.class)
\r
47 public void testNullCheck2(){
\r
48 String[] elementA = new String[] { "load", "load", "add", "store", };
\r
50 calculator.calculate(elementA, null);
\r
53 @Test(expected=NullPointerException.class)
\r
54 public void testNullCheck3(){
\r
55 calculator.calculate(null, null);
\r