public void ConvertInfixToReversePolishNotation_NoWhitespace() { var rpn = CompilerDataAllocationDirective.ConvertInfixToReversePolishNotation <UInt32>("$-msg2".Split(' '), 0).ToArray(); Assert.Equal(3, rpn.Length); Assert.Equal(0, rpn[0]); Assert.Equal("msg2", rpn[1]); Assert.Equal("-", rpn[2]); }
public void ConvertInfixToReversePolishNotation_Simple_Symbolic_Subtraction() { // A-B => A B - var rpn = CompilerDataAllocationDirective.ConvertInfixToReversePolishNotation <UInt32>(new string[] { "A", "-", "B" }, 0).ToArray(); Assert.Equal(3, rpn.Length); Assert.Equal("A", rpn[0]); Assert.Equal("B", rpn[1]); Assert.Equal("-", rpn[2]); }
public void ConvertInfixToReversePolishNotation_Simple_Number_Subtraction() { // 3-1 => 3 1 - var rpn = CompilerDataAllocationDirective.ConvertInfixToReversePolishNotation <UInt32>(new string[] { "3", "-", "1" }, 0).ToArray(); Assert.Equal(3, rpn.Length); Assert.Equal((byte)3, rpn[0]); Assert.Equal((byte)1, rpn[1]); Assert.Equal("-", rpn[2]); }
public void ConvertInfixToReversePolishNotation_Complex_Symbolic_Multiple() { // A ^ 2 + 3 * A * B + B ^ 4 => A 2 ^ 3 A * B * + B 4 ^ + var rpn = CompilerDataAllocationDirective.ConvertInfixToReversePolishNotation <UInt32>("A ^ 2 + 3 * A * B + B ^ 4".Split(' '), 0).ToArray(); Assert.Equal(13, rpn.Length); Assert.Equal("A", rpn[0]); Assert.Equal((byte)2, rpn[1]); Assert.Equal("^", rpn[2]); Assert.Equal((byte)3, rpn[3]); Assert.Equal("A", rpn[4]); Assert.Equal("*", rpn[5]); Assert.Equal("B", rpn[6]); Assert.Equal("*", rpn[7]); Assert.Equal("+", rpn[8]); Assert.Equal("B", rpn[9]); Assert.Equal((byte)4, rpn[10]); Assert.Equal("^", rpn[11]); Assert.Equal("+", rpn[12]); }