OSDN Git Service

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