OSDN Git Service

修正・変更
[chemicraft/chemicraft.git] / common / pcc / chemicraft / testcase / FormulaTest.java
1 /*
2 package pcc.chemicraft.testcase;
3
4 import static org.junit.Assert.*;
5
6 import java.util.Arrays;
7
8 import org.junit.Test;
9
10 import pcc.chemicraft.util.Formula;
11
12 public class FormulaTest extends Formula {
13
14         public FormulaTest() {
15                 super("");
16         }
17
18         @Test
19         public void test8() {
20                 Formula formula_Together = new Formula("Si12Si3C2O8C4");
21                 check(formula_Together.getAtoms(), formula_Together.getAmonts(), new String[] {"Si", "C", "O"}, new Integer[] {12+3, 2+4, 8});
22         }
23
24         @Test
25         public void test7() {
26                 Formula formula_first_no_ten__other_ten = new Formula("Si6C11O56");
27                 check(formula_first_no_ten__other_ten.getAtoms(), formula_first_no_ten__other_ten.getAmonts(), new String[] {"Si", "C", "O"}, new Integer[] {6, 11, 56});
28         }
29
30         @Test
31         public void test6() {
32                 Formula formula_multiple_and_ten = new Formula("Si13O47");
33                 check(formula_multiple_and_ten.getAtoms(), formula_multiple_and_ten.getAmonts(), new String[] {"Si", "O"}, new Integer[] {13, 47});
34         }
35
36         @Test
37         public void test5() {
38                 Formula formula_ten = new Formula("Si13");
39                 check(formula_ten.getAtoms(), formula_ten.getAmonts(), new String[] {"Si"}, new Integer[] {13});
40         }
41
42         @Test
43         public void test4() {
44                 Formula formula_firstSimple__other_In_Numer = new Formula("SiC2O2");
45                 check(formula_firstSimple__other_In_Numer.getAtoms(), formula_firstSimple__other_In_Numer.getAmonts(), new String[] {"Si", "C", "O"}, new Integer[] {1, 2, 2});
46         }
47
48         @Test
49         public void test3() {
50                 Formula formula_multiple_and_in_number = new Formula("Si2C2O2");
51                 check(formula_multiple_and_in_number.getAtoms(), formula_multiple_and_in_number.getAmonts(), new String[] {"Si", "C", "O"}, new Integer[] {2, 2, 2});
52         }
53
54         @Test
55         public void test2() {
56                 Formula formula_multiple = new Formula("SiCO");
57                 check(formula_multiple.getAtoms(), formula_multiple.getAmonts(), new String[] {"Si", "C", "O"}, new Integer[] {1, 1, 1});
58         }
59
60         @Test
61         public void test1() {
62                 Formula formula_in_number = new Formula("Si3");
63                 check(formula_in_number.getAtoms(), formula_in_number.getAmonts(), new String[] {"Si"}, new Integer[] {3});
64         }
65
66         @Test
67         public void test() {
68                 Formula formula_simple = new Formula("Si");
69                 check(formula_simple.getAtoms(), formula_simple.getAmonts(), new String[] {"Si"}, new Integer[] {1});
70         }
71
72         public void check(String[] atoms, Integer[] amounts, String[] expectaionAtoms, Integer[] expectationAmounts) {
73                 assertEquals("変換がおかしいです(元素)",
74                                 atoms,
75                                 expectaionAtoms);
76
77                 assertEquals("変換がおかしいです(元素数)",
78                                 amounts,
79                                 expectationAmounts);
80         }
81
82 }
83 */