From b00cf1900c613d5ac47bec684c01492b2db742c7 Mon Sep 17 00:00:00 2001 From: Daniel Grunwald Date: Mon, 14 Feb 2011 16:51:02 +0100 Subject: [PATCH] Add parentheses test for "a + (b == null ? c : d)" --- .../CSharp/InsertParenthesesVisitorTests.cs | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/ICSharpCode.NRefactory.Tests/CSharp/InsertParenthesesVisitorTests.cs b/ICSharpCode.NRefactory.Tests/CSharp/InsertParenthesesVisitorTests.cs index 1415ca3f38..fd044068fd 100644 --- a/ICSharpCode.NRefactory.Tests/CSharp/InsertParenthesesVisitorTests.cs +++ b/ICSharpCode.NRefactory.Tests/CSharp/InsertParenthesesVisitorTests.cs @@ -108,6 +108,27 @@ namespace ICSharpCode.NRefactory.CSharp Assert.AreEqual("-(-a)", InsertReadable(expr)); } + [Test] + public void AdditionWithConditional() + { + Expression expr = new BinaryOperatorExpression { + Left = new IdentifierExpression("a"), + Operator = BinaryOperatorType.Add, + Right = new ConditionalExpression { + Condition = new BinaryOperatorExpression { + Left = new IdentifierExpression("b"), + Operator = BinaryOperatorType.Equality, + Right = new PrimitiveExpression(null) + }, + TrueExpression = new IdentifierExpression("c"), + FalseExpression = new IdentifierExpression("d") + } + }; + + Assert.AreEqual("a + (b == null ? c : d)", InsertRequired(expr)); + Assert.AreEqual("a + ((b == null) ? c : d)", InsertReadable(expr)); + } + [Test] public void TypeTestInConditional() {