public void chompEscapedBalanced() { TokenQueue tq = new TokenQueue(":contains(one (two) \\( \\) \\) three) four"); string pre = tq.ConsumeTo("("); string guts = tq.ChompBalanced('(', ')'); string remainder = tq.Remainder(); Assert.AreEqual(":contains", pre); Assert.AreEqual("one (two) \\( \\) \\) three", guts); Assert.AreEqual("one (two) ( ) ) three", TokenQueue.Unescape(guts)); Assert.AreEqual(" four", remainder); }
// pseudo selector :contains(text), containsOwn(text) private void Contains(bool own) { tq.Consume(own ? ":containsOwn" : ":contains"); String searchText = TokenQueue.Unescape(tq.ChompBalanced('(', ')')); Validate.NotEmpty(searchText, ":contains(text) query must not be empty"); if (own) { evals.Add(new Evaluator.ContainsOwnText(searchText)); } else { evals.Add(new Evaluator.ContainsText(searchText)); } }
private Evaluator Contains(bool own, string tq) { string searchText = TokenQueue.Unescape(tq); if (searchText.Length == 0) { throw DomFailure.ContainsSelectorCannotBeEmpty(); } if (own) { return(new Evaluator.ContainsOwnText(searchText)); } return(new Evaluator.ContainsText(searchText)); }
// pseudo selector :contains(text), containsOwn(text) private void Contains(bool own) { _tq.Consume(own ? ":containsOwn" : ":contains"); string searchText = TokenQueue.Unescape(_tq.ChompBalanced('(', ')')); if (string.IsNullOrEmpty(searchText)) { throw new Exception(":contains(text) query must not be empty"); } if (own) { _evals.Add(new Evaluator.ContainsOwnText(searchText)); } else { _evals.Add(new Evaluator.ContainsText(searchText)); } }
public void unescape() { Assert.AreEqual("one ( ) \\", TokenQueue.Unescape("one \\( \\) \\\\")); }