| | |
| | | 0, |
| | | ] |
| | | sci2_solutions = [ |
| | | "1.2", |
| | | "1.2", |
| | | "3.0", |
| | | "3.5", |
| | | "5.0 \cdot 10^{-2}", |
| | | "-1.2", |
| | | "-3.0", |
| | | "1.1 \cdot 10^{-6}", |
| | | "-1.1 \cdot 10^{6}", |
| | | "9.8 \cdot 10^{255}", |
| | | "0.0", |
| | | "1,\!2", |
| | | "1,\!2", |
| | | "3,\!0", |
| | | "3,\!5", |
| | | "5,\!0 \cdot 10^{-2}", |
| | | "-1,\!2", |
| | | "-3,\!0", |
| | | "1,\!1 \cdot 10^{-6}", |
| | | "-1,\!1 \cdot 10^{6}", |
| | | "9,\!8 \cdot 10^{255}", |
| | | "0,\!0", |
| | | ] |
| | | |
| | | sci3_solutions = [ |
| | | "1.24", |
| | | "1.20", |
| | | "3.00", |
| | | "3.50", |
| | | "5.00 \cdot 10^{-2}", |
| | | "-1.23", |
| | | "-3.00", |
| | | "1.12 \cdot 10^{-6}", |
| | | "-1.12 \cdot 10^{6}", |
| | | "9.81 \cdot 10^{255}", |
| | | "0.00", |
| | | "1,\!24", |
| | | "1,\!20", |
| | | "3,\!00", |
| | | "3,\!50", |
| | | "5,\!00 \cdot 10^{-2}", |
| | | "-1,\!23", |
| | | "-3,\!00", |
| | | "1,\!12 \cdot 10^{-6}", |
| | | "-1,\!12 \cdot 10^{6}", |
| | | "9,\!81 \cdot 10^{255}", |
| | | "0,\!00", |
| | | ] |
| | | |
| | | |
| | | sci2 = Variable.FormatterFactory().get_formatter("sci 2") |
| | | for case, result in zip(testcases, sci2_solutions): |
| | | self.assertEqual(result, sci2.toFormat(case)) |
| | |
| | | sci3 = Variable.FormatterFactory().get_formatter("sci 3") |
| | | for case, result in zip(testcases, sci3_solutions): |
| | | self.assertEqual(result, sci3.toFormat(case)) |
| | | |
| | | |
| | | |
| | | def test_additionalDecTests(self): |
| | | testcases = [ |
| | | 1.235678910111213, |
| | | 1.2, |
| | | 3, |
| | | "3.5", |
| | | "0.05", |
| | | -1.2343567, |
| | | -3, |
| | | 1.123e-6, |
| | | -1.123e6, |
| | | 0, |
| | | 32, |
| | | ] |
| | | dec2_solutions = [ |
| | | "1,\!2", |
| | | "1,\!2", |
| | | "3,\!0", |
| | | "3,\!5", |
| | | "0,\!050", |
| | | "-1,\!2", |
| | | "-3,\!0", |
| | | "0,\!0000011", |
| | | "-1100000", |
| | | "0,\!0", |
| | | "32" |
| | | ] |
| | | dec1_solutions=[ |
| | | "1", |
| | | "1", |
| | | "3", |
| | | "4", |
| | | "0,\!05", |
| | | "-1", |
| | | "-3", |
| | | "0,\!000001", |
| | | "-1000000", |
| | | "0", |
| | | "30", |
| | | ] |
| | | |
| | | dec2 = Variable.FormatterFactory().get_formatter("dec 2") |
| | | for case, result in zip(testcases, dec2_solutions): |
| | | self.assertEqual(result, dec2.toFormat(case)) |
| | | |
| | | dec1 = Variable.FormatterFactory().get_formatter("dec 1") |
| | | for case, result in zip(testcases, dec1_solutions): |
| | | self.assertEqual(result, dec1.toFormat(case)) |
| | | |
| | | def test_valueClass(self): |
| | | testcases = [ |
| | |
| | | 0, |
| | | ] |
| | | sci2_solutions = [ |
| | | "1.2", |
| | | "1.2", |
| | | "3.0", |
| | | "3.5", |
| | | "5.0 \cdot 10^{-2}", |
| | | "-1.2", |
| | | "-3.0", |
| | | "1.1 \cdot 10^{-6}", |
| | | "-1.1 \cdot 10^{6}", |
| | | "9.8 \cdot 10^{255}", |
| | | "0.0", |
| | | "$1,\!2\,$", |
| | | "$1,\!2\,$", |
| | | "$3,\!0\,$", |
| | | "$3,\!5\,$", |
| | | "$5,\!0 \cdot 10^{-2}\,$", |
| | | "$-1,\!2\,$", |
| | | "$-3,\!0\,$", |
| | | "$1,\!1 \cdot 10^{-6}\,$", |
| | | "$-1,\!1 \cdot 10^{6}\,$", |
| | | "$9,\!8 \cdot 10^{255}\,$", |
| | | "$0,\!0\,$", |
| | | ] |
| | | |
| | | sci3_solutions = [ |
| | | "1.24", |
| | | "1.20", |
| | | "3.00", |
| | | "3.50", |
| | | "5.00 \cdot 10^{-2}", |
| | | "-1.23", |
| | | "-3.00", |
| | | "1.12 \cdot 10^{-6}", |
| | | "-1.12 \cdot 10^{6}", |
| | | "9.81 \cdot 10^{255}", |
| | | "0.00", |
| | | "$1,\!24\,$", |
| | | "$1,\!20\,$", |
| | | "$3,\!00\,$", |
| | | "$3,\!50\,$", |
| | | "$5,\!00 \cdot 10^{-2}\,$", |
| | | "$-1,\!23\,$", |
| | | "$-3,\!00\,$", |
| | | "$1,\!12 \cdot 10^{-6}\,$", |
| | | "$-1,\!12 \cdot 10^{6}\,$", |
| | | "$9,\!81 \cdot 10^{255}\,$", |
| | | "$0,\!00\,$", |
| | | ] |
| | | |
| | | sci2_rounded = [ |