From 00773938636bd3a172b3c9bdff345888104b3cea Mon Sep 17 00:00:00 2001 From: mozipi Date: Fri, 12 Apr 2013 23:03:41 +0900 Subject: [PATCH] =?utf8?q?Formula=E3=82=AF=E3=83=A9=E3=82=B9=E3=81=AE?= =?utf8?q?=E3=83=86=E3=82=B9=E3=83=88=E3=82=B1=E3=83=BC=E3=82=B9=E4=BD=9C?= =?utf8?q?=E3=81=A3=E3=81=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- common/pcc/chemicraft/testcase/FormulaTest.java | 63 ++++++++++++++++++++++--- 1 file changed, 57 insertions(+), 6 deletions(-) diff --git a/common/pcc/chemicraft/testcase/FormulaTest.java b/common/pcc/chemicraft/testcase/FormulaTest.java index 6e5da59..31f2a43 100644 --- a/common/pcc/chemicraft/testcase/FormulaTest.java +++ b/common/pcc/chemicraft/testcase/FormulaTest.java @@ -15,16 +15,67 @@ public class FormulaTest extends Formula { } @Test + public void test8() { + Formula formula_Together = new Formula("Si12Si3C2O8C4"); + check(formula_Together.getAtoms(), formula_Together.getAmonts(), new String[] {"Si", "C", "O"}, new Integer[] {12+3, 2+4, 8}); + } + + @Test + public void test7() { + Formula formula_first_no_ten__other_ten = new Formula("Si6C11O56"); + 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}); + } + + @Test + public void test6() { + Formula formula_multiple_and_ten = new Formula("Si13O47"); + check(formula_multiple_and_ten.getAtoms(), formula_multiple_and_ten.getAmonts(), new String[] {"Si", "O"}, new Integer[] {13, 47}); + } + + @Test + public void test5() { + Formula formula_ten = new Formula("Si13"); + check(formula_ten.getAtoms(), formula_ten.getAmonts(), new String[] {"Si"}, new Integer[] {13}); + } + + @Test + public void test4() { + Formula formula_firstSimple__other_In_Numer = new Formula("SiC2O2"); + check(formula_firstSimple__other_In_Numer.getAtoms(), formula_firstSimple__other_In_Numer.getAmonts(), new String[] {"Si", "C", "O"}, new Integer[] {1, 2, 2}); + } + + @Test + public void test3() { + Formula formula_multiple_and_in_number = new Formula("Si2C2O2"); + check(formula_multiple_and_in_number.getAtoms(), formula_multiple_and_in_number.getAmonts(), new String[] {"Si", "C", "O"}, new Integer[] {2, 2, 2}); + } + + @Test + public void test2() { + Formula formula_multiple = new Formula("SiCO"); + check(formula_multiple.getAtoms(), formula_multiple.getAmonts(), new String[] {"Si", "C", "O"}, new Integer[] {1, 1, 1}); + } + + @Test + public void test1() { + Formula formula_in_number = new Formula("Si3"); + check(formula_in_number.getAtoms(), formula_in_number.getAmonts(), new String[] {"Si"}, new Integer[] {3}); + } + + @Test public void test() { - Formula formula = new Formula("Si10C19O211Si128C12O11Ca198"); + Formula formula_simple = new Formula("Si"); + check(formula_simple.getAtoms(), formula_simple.getAmonts(), new String[] {"Si"}, new Integer[] {1}); + } + + public void check(String[] atoms, Integer[] amounts, String[] expectaionAtoms, Integer[] expectationAmounts) { assertEquals("変換がおかしいです(元素)", - formula.getAtoms(), - new String[] {"Si", "C", "O", "Ca"}); + atoms, + expectaionAtoms); assertEquals("変換がおかしいです(元素数)", - formula.getAmonts(), - new Integer[] {10+128, 19+12, 211+11, 198}); - + amounts, + expectationAmounts); } } -- 2.11.0