public void CssToken_Compare() { ITextProvider text = new StringTextProvider("abcdef"); CssToken t1 = new CssToken(CssTokenType.DoubleColon, 1, 2); CssToken t2 = new CssToken(CssTokenType.DoubleColon, 0, 2); Assert.IsTrue(CssToken.CompareTokens(t1, t2, text, text)); t2.TokenType = CssTokenType.Colon; Assert.IsFalse(CssToken.CompareTokens(t1, t2, text, text)); t1.TokenType = CssTokenType.Identifier; t2.TokenType = CssTokenType.Identifier; Assert.IsFalse(CssToken.CompareTokens(t1, t2, text, text)); t2 = new CssToken(t1.TokenType, t1.Start, t1.Length); Assert.IsTrue(CssToken.CompareTokens(t1, t2, text, text)); }
private void VerifyTokensAfterIncrementalChange(ICssTokenizerFactory tokenizerFactory, ITextProvider newText, TokenList newTokens) { ICssTokenizer tokenizer = tokenizerFactory.CreateTokenizer(); TokenList validTokens = tokenizer.Tokenize(newText, 0, newText.Length, keepWhiteSpace: false); if (validTokens.Count == newTokens.Count) { for (int i = 0; i < validTokens.Count && i < newTokens.Count; i++) { if (!CssToken.CompareTokens(validTokens[i], newTokens[i], newText, newText)) { Debug.Fail("The CssTree.Tokens list is bad"); break; } } } else { Debug.Fail("The CssTree.Tokens list is bad, wrong number of tokens"); } }