def test_value_or_more(self): assert ValueOrMore(4).quantify(String("1")) == "1111"
def test_value_or_less(self): assert ValueOrLess(4).quantify(String("1")) == ""
def stringify(self, string_expression): return String(str(string_expression))
def test_group_within_a_group(self): assert Quantified(Quantified(String("A"), Exactly(1)), Exactly(1)) == "A"
def test_value_or_more(self): quantifier = QuantifierFactory.get(RegularExpression("{4,}")) assert quantifier.quantify(String("4")) == "4444"
def test_plus(self): quantifier = QuantifierFactory.get(RegularExpression("+")) assert quantifier.quantify(String("4")) == "4"
def test_group_with_multiple_items_multiplication(self): assert Group([String("abc"), Quantified(String("def"), Exactly(2)) ]) * 2 == "abcdefdefabcdefdef"
def test_exactly(self): quantifier = QuantifierFactory.get(RegularExpression("{3}")) assert quantifier.quantify(String("4")) == "444"
def test_group_within_a_group(self): assert Group([Group([String("abc")])]) == "abc"
def test_group_with_a_single_item_multiplication(self): assert Group([String("abc")]) * 2 == "abcabc"
def test_group_with_a_single_item(self): assert Group([String("abc")]) == "abc"
def test_str(self): assert Quantified(String("1"), Exactly(1)) == "1"
def test_multiplication(self): assert (Quantified(String("1"), Exactly(1)) * 2) * 2 == "1111"
def test_between(self): assert Between(1, 4).quantify(String("f")) == "f" assert Between(0, 4).quantify(String("f")) == "" assert Between(2, 4).quantify(String("f")) == "ff"
def test_group_within_a_group_multiplication(self): assert Group([Group([String("abc")])]) * 2 == "abcabc"
def test_question_mark(self): quantifier = QuantifierFactory.get(RegularExpression("?")) assert quantifier.quantify(String("4")) == ""
def test_exactly(self): assert Exactly(1).quantify(String("1")) == "1" assert Exactly(0).quantify(String("1")) == "" assert Exactly(2).quantify(String("1")) == "11"
def test_between(self): quantifier = QuantifierFactory.get(RegularExpression("{5,6}")) assert quantifier.quantify(String("4")) == "44444"
def test_one_or_more(self): assert OneOrMore().quantify(String("111")) == "111"
def test_value_or_less(self): quantifier = QuantifierFactory.get(RegularExpression("{,4}")) assert quantifier.quantify(String("4")) == ""
def test_zero_or_more(self): assert ZeroOrMore().quantify(String("1")) == ""
def test_string_multiplication(self): assert String("F") * 4 == "FFFF"
def test_zero_or_one(self): assert ZeroOrOne().quantify(String("1")) == ""
def __mul__(self, other): return String(str(self)) * other
def test_quantifiers(self): assert Quantified(String("A"), Exactly(2)) == "AA"