public void testErotaDouble105() { Assert.AreEqual(0.0, Taulukot.ErotaDouble(""), 0.000001, "in method ErotaDouble, line 106"); Assert.AreEqual(2.3, Taulukot.ErotaDouble(" 2.3 "), 0.000001, "in method ErotaDouble, line 107"); Assert.AreEqual(5, Taulukot.ErotaDouble("5 3"), 0.000001, "in method ErotaDouble, line 108"); Assert.AreEqual(5, Taulukot.ErotaDouble("5k3"), 0.000001, "in method ErotaDouble, line 109"); Assert.AreEqual(5000, Taulukot.ErotaDouble("5e3"), 0.000001, "in method ErotaDouble, line 110"); Assert.AreEqual(0.005, Taulukot.ErotaDouble("5E-3"), 0.000001, "in method ErotaDouble, line 111"); Assert.AreEqual(0.0, Taulukot.ErotaDouble("k"), 0.000001, "in method ErotaDouble, line 112"); Assert.AreEqual(1.0, Taulukot.ErotaDouble("k", 1.0), 0.000001, "in method ErotaDouble, line 113"); Assert.AreEqual(0.0, Taulukot.ErotaDouble("2..3"), 0.000001, "in method ErotaDouble, line 114"); }
/// <summary> /// Testataan taulukkoaliohjelmia /// </summary> public static void Main() { Taulukot.ErotaDouble("k", 1); double[,] mat1 = { { 1, 2, 3 }, { 2, 2, 2 }, { 4, 2, 3 } }; double[,] mat2 = { { 9, 2, 8 }, { 1, 2, 5 }, { 3, 19, -3 } }; double[,] mat3 = Taulukot.Summa(mat1, mat2); Console.WriteLine(Matriisit.Jonoksi(mat3, " ", "{0,5:0.00}")); double[] luvut = Taulukot.ErotaLuvut("2.23 3 4 5 k 9 ;5"); Console.WriteLine(Matriisit.Jonoksi(luvut, " ", "{0,5:0.00}")); double[] l2 = luvut; Array.Resize(ref l2, 10); Console.WriteLine(Matriisit.Jonoksi(luvut, " ", "{0,5:0.00}")); Console.WriteLine(Matriisit.Jonoksi(l2, " ", "{0,5:0.00}")); l2 = luvut; Array.Resize(ref l2, 4); Console.WriteLine(Matriisit.Jonoksi(luvut, " ", "{0,5:0.00}")); Console.WriteLine(Matriisit.Jonoksi(l2, " ", "{0,5:0.00}")); }