Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Program
- {
- static void verify(string input, int res)
- {
- Calculate line = new Calculate(input);
- int got = line.calculateIt();
- if (got != res) Console.Write("For " + input + " Value = " + got + " Expexted : " + res + "\n");
- }
- static void verify(string input, string res)
- {
- CalculateX line = new CalculateX(input);
- string got = line.calculateIt();
- if (Convert.ToBoolean(string.Compare(got,res)) ) Console.Write("For " + input + " Value = " + got + " Expexted : " + res + "\n");
- }
- static void runTests()
- {
- verify("15+5*11", 70);
- verify("-24-16+77", 37);
- verify("12*3*7-15*8", 132);
- verify("-15*9+65", -70);
- verify("3-2*-5*3*-2+7", -50);
- verify("5*12*-5*-3", 900);
- verify("7+9*-4+23", -6);
- verify("12+(22+5*-3-15)", 4);
- verify("((5-2)*3)-9", 0);
- verify("-(10-15)*5+23", 48);
- verify("(5-1)*(2-4)", -8);
- verify("12+(-12+7)*5", -13);
- verify("[([5-2]*[3])-9]", 0);
- verify("2*x-6+x 4 7", "6 9 12 15 ");
- verify("2*q-6+q 4 7", "6 9 12 15 ");
- verify("4^2*3", 48);
- verify("4*-3^2", -36);
- verify("(5-1)^(4-2)", 16);
- verify("(-1)^(4-2)", 1);
- verify("(-2)^(3)", -8);
- }
- static void Main(string[] args)
- {
- runTests();
- string input = Console.ReadLine();
- CalculateX line = new CalculateX(input);
- string res = line.calculateIt ();
- Console.Write(res);
- Console.ReadKey();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement