def test_example_a(): expressions = [ '1 + (2 * 3) + (4 * (5 + 6))', '2 * 3 + (4 * 5)', '5 + (8 * 3 + 9 + 3 * 4 * 3)' ] result = solver.solve_a( reader.read_lines(expressions, operators={ '+': 0, '*': 0 })) assert_that(result).is_equal_to(514)
def test_example_a_1(): lines = ['1 + 2 * 3 + 4 * 5 + 6\n'] result = reader.read_lines(lines, operators={'+': 0, '*': 0}) assert_that(result).is_equal_to([('+', ('*', ('+', ('*', ('+', 1, 2), 3), 4), 5), 6)])
def test_example_b_2(): lines = ['1 + (2 * 3) + (4 * (5 + 6))\n'] result = reader.read_lines(lines, operators={'+': 1, '*': 0}) assert_that(result).is_equal_to([('+', ('+', 1, ('*', 2, 3)), ('*', 4, ('+', 5, 6)))])