Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
02/06/18 16:21:16 (7 years ago)
Author:
lkammere
Message:

#2886: Refactor tree hash function.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2886_SymRegGrammarEnumeration/Test/TreeHashingTest.cs

    r15714 r15725  
    8181      Assert.AreEqual(hash1, hash2);
    8282    }
     83
     84    [TestMethod]
     85    [TestCategory("TreeHashing")]
     86    public void ComplexInequality() {
     87      SymbolString s1 = new SymbolString(new[] { varA, varA, varA, grammar.Multiplication, grammar.Multiplication });
     88      SymbolString s2 = new SymbolString(new[] { varA, varA, varA, grammar.Multiplication, grammar.Addition });
     89
     90      int hash1 = grammar.CalcHashCode(s1);
     91      int hash2 = grammar.CalcHashCode(s2);
     92
     93      Assert.AreNotEqual(hash1, hash2);
     94    }
     95
     96
     97    #region parser
     98
     99    [TestMethod]
     100    [TestCategory("Parser")]
     101    public void InfixParserSimpleTest() {
     102      SymbolString postfix = new SymbolString(new[] { varA, varB, varC, grammar.Addition, grammar.Addition });
     103      SymbolString infix = new SymbolString(new[] { varA, grammar.Addition, varB, grammar.Addition, varC });
     104
     105      Assert.AreEqual(infix.ToString(), grammar.PostfixToInfixParser(postfix).ToString());
     106    }
     107
     108    [TestMethod]
     109    [TestCategory("Parser")]
     110    public void InfixParserComplexTest() {
     111      SymbolString postfix = new SymbolString(new[] { varB, varA, varB, varC, grammar.Multiplication, grammar.Addition, grammar.Addition});
     112      SymbolString infix = new SymbolString(new[] { varB, grammar.Addition, varA, grammar.Addition, varB, grammar.Multiplication, varC });
     113
     114      Assert.AreEqual(infix.ToString(), grammar.PostfixToInfixParser(postfix).ToString());
     115    }
     116
     117    #endregion
    83118  }
    84119}
Note: See TracChangeset for help on using the changeset viewer.