def test_evaluate_3var_expr(self):
     expr = 'a & b | c'
     variableMap = {'a' : 0, 'b' : 1 , 'c' : 0 }
     postfix = infixToPostfix(expr)
     root = postfixToExpressionTree(postfix)
     root.in_traversal()
     print('')
     self.assertEqual(evaluateExpr(postfix, variableMap), 0)
 def test_evaluate_expr_true(self):
     expr = 'a | !a'
     variableMap = {'a' : 0}
     postfix = infixToPostfix(expr)
     root = postfixToExpressionTree(postfix)
     root.in_traversal()
     print('')
     self.assertEqual(evaluateExpr(postfix, variableMap), 1)
 def test_evaluate_complex_expr(self):
     expr = '(a & (!b | b)) | (!a & (!b | b))'
     variableMap = {'a' : 0, 'b' : 1}
     postfix = infixToPostfix(expr)
     root = postfixToExpressionTree(postfix)
     root.in_traversal()
     print('')
     self.assertEqual(evaluateExpr(postfix, variableMap), 1)
 def test_evaluate_expr_simple(self):
     expr = 'a'
     variableMap = {'a' : 0}
     postfix = infixToPostfix(expr)
     self.assertEqual(evaluateExpr(postfix, variableMap), 0)