OSDN Git Service

cflib は plugins プロジェクトから,Stigmata直下のプロジェクトに移行したため,このリポジトリからは削除した.
[stigmata/stigmata-plugins.git] / osb / src / test / java / jp / sourceforge / stigmata / birthmarks / osb / OperandStackBehaviorsBirthmarkComparatorTest.java
1 package jp.sourceforge.stigmata.birthmarks.osb;\r
2 \r
3 import jp.sourceforge.stigmata.Birthmark;\r
4 import jp.sourceforge.stigmata.BirthmarkExtractionFailedException;\r
5 import junit.framework.Assert;\r
6 \r
7 import org.junit.Before;\r
8 import org.junit.Test;\r
9 \r
10 public class OperandStackBehaviorsBirthmarkComparatorTest{\r
11     private OperandStackBehaviorsBirthmarkComparator comparator;\r
12     private OperandStackBehaviorsBirthmarkExtractor extractor;\r
13 \r
14     @Before\r
15     public void setUp(){\r
16         OperandStackBehaviorsBirthmarkService service = new OperandStackBehaviorsBirthmarkService();\r
17         comparator = (OperandStackBehaviorsBirthmarkComparator)service.getComparator();\r
18         extractor = (OperandStackBehaviorsBirthmarkExtractor)service.getExtractor();\r
19     }\r
20 \r
21     @Test\r
22     public void testBasic() throws BirthmarkExtractionFailedException{\r
23         Birthmark birthmark1 = extractor.extract(getClass().getResourceAsStream("/resources/Sample1.class"));\r
24         Birthmark birthmark2 = extractor.extract(getClass().getResourceAsStream("/resources/Sample2.class"));\r
25 \r
26         Assert.assertEquals(7, birthmark1.getElementCount());\r
27         Assert.assertEquals(8, birthmark2.getElementCount());\r
28 \r
29         Assert.assertEquals(7d / 8, comparator.compare(birthmark1, birthmark2, null), 1E-6);\r
30     }\r
31 }\r