Beispiel #1
0
        public void Should_prioritize_parentheses(string expression, int expected)
        {
            var calc = new ConfigurableOperatorPrecedenceCalculator();

            var result = calc.Evaluate(expression);

            Assert.Equal(expected, result);
        }
Beispiel #2
0
        public void Examples_A(string expression, int expected)
        {
            var calc = new ConfigurableOperatorPrecedenceCalculator();

            var result = calc.Evaluate(expression);

            Assert.Equal(expected, result);
        }
Beispiel #3
0
        public void Should_handle_multiplication(string expression, int expected)
        {
            var calc = new ConfigurableOperatorPrecedenceCalculator();

            var result = calc.Evaluate(expression);

            Assert.Equal(expected, result);
        }
Beispiel #4
0
        public void Puzzle_18B()
        {
            var calc = new ConfigurableOperatorPrecedenceCalculator
            {
                ObserveOperatorPrecedence = true
            };
            long acc = 0;

            foreach (var expression in PuzzleInput)
            {
                acc += calc.Evaluate(expression);
            }

            Assert.Equal(362880372308125, acc);
        }