public void SignPrecedence() { var eq = new ImageFramework.Model.Equation.Equation("-1+2"); var hlsl = eq.GetHlslExpression(); var expected = $"(({NumberToken.ToHlsl(-1.0f)}*{NumberToken.ToHlsl(1.0f)})+{NumberToken.ToHlsl(2.0f)})"; Assert.AreEqual(expected, hlsl.Replace(" ", "")); }
public void SignOperatorAndBrackets() { var eq = new ImageFramework.Model.Equation.Equation("1+0.4*-2"); var hlsl = eq.GetHlslExpression(); var expected = $"({NumberToken.ToHlsl(1.0f)}+({NumberToken.ToHlsl(0.4f)}*({NumberToken.ToHlsl(-1.0f)}*{NumberToken.ToHlsl(2.0f)})))"; Assert.AreEqual(expected, hlsl.Replace(" ", "")); }
public void OperatorPrecedence() { var eq = new ImageFramework.Model.Equation.Equation("(3-1)*0.4+1"); var hlsl = eq.GetHlslExpression(); var expected = $"((({NumberToken.ToHlsl(3.0f)}-{NumberToken.ToHlsl(1.0f)})*{NumberToken.ToHlsl(0.4f)})+{NumberToken.ToHlsl(1.0f)})"; Assert.AreEqual(expected, hlsl.Replace(" ", "")); eq = new ImageFramework.Model.Equation.Equation("1+0.4*(3-1)"); hlsl = eq.GetHlslExpression(); expected = $"({NumberToken.ToHlsl(1.0f)}+({NumberToken.ToHlsl(0.4f)}*({NumberToken.ToHlsl(3.0f)}-{NumberToken.ToHlsl(1.0f)})))"; Assert.AreEqual(expected, hlsl.Replace(" ", "")); }