OSDN Git Service

cflib は plugins プロジェクトから,Stigmata直下のプロジェクトに移行したため,このリポジトリからは削除した.
[stigmata/stigmata-plugins.git] / osb / src / test / java / jp / sourceforge / stigmata / birthmarks / osb / LCSCalculatorTest.java
1 package jp.sourceforge.stigmata.birthmarks.osb;\r
2 \r
3 import org.junit.Assert;\r
4 import org.junit.Before;\r
5 import org.junit.Test;\r
6 \r
7 public class LCSCalculatorTest{\r
8     private LCSCalculator<String> calculator;\r
9 \r
10     @Before\r
11     public void setUp(){\r
12         calculator = new LCSCalculator<String>();\r
13     }\r
14 \r
15     @Test\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
19 \r
20         Assert.assertEquals(3, calculator.calculate(elementA, elementB));\r
21         Assert.assertEquals(3, calculator.calculate(elementB, elementA));\r
22     }\r
23 \r
24     @Test\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
28 \r
29         Assert.assertEquals(3, calculator.calculate(elementA, elementB));\r
30     }\r
31 \r
32     @Test\r
33     public void testZeroLengthArray(){\r
34         String[] elementB = new String[] { "load", "load", "mul", "load", "sub", "store", };\r
35 \r
36         Assert.assertEquals(0, calculator.calculate(new String[0], elementB));\r
37     }\r
38 \r
39     @Test(expected=NullPointerException.class)\r
40     public void testNullCheck1(){\r
41         String[] elementB = new String[] { "load", "load", "mul", "load", "sub", "store", };\r
42 \r
43         calculator.calculate(null, elementB);\r
44     }\r
45 \r
46     @Test(expected=NullPointerException.class)\r
47     public void testNullCheck2(){\r
48         String[] elementA = new String[] { "load", "load", "add", "store", };\r
49 \r
50         calculator.calculate(elementA, null);\r
51     }\r
52 \r
53     @Test(expected=NullPointerException.class)\r
54     public void testNullCheck3(){\r
55         calculator.calculate(null, null);\r
56     }\r
57 }\r