コード例 #1
0
def test_cond_next2():
    # Get position:
    text = ",ab"
    nested = u.nest(text)
    assert u.cond_next(text, ",", nested, nested[0]) == 0
    text = "a,b"
    nested = u.nest(text)
    assert u.cond_next(text, ",", nested, nested[0]) == 1
コード例 #2
0
def test_cond_next3():
    # Protected:
    text = "{a,b}"
    nested = u.nest(text)
    assert u.cond_next(text, ",", nested, nested[0]) == 4
    text = "{a,b},c"
    nested = u.nest(text)
    assert u.cond_next(text, ",", nested, nested[0]) == 5
    text = "{a and b} and c"
    nested = u.nest(text)
    assert u.cond_next(text, " and ", nested, nested[0]) == 9
コード例 #3
0
def test_cond_next1():
    # Empty string:
    text = ""
    nested = u.nest(text)
    assert u.cond_next(text, ",", nested, nested[0:1]) == 0
    # Pattern not found in text, return last index:
    text = "ab"
    nested = u.nest(text)
    assert u.cond_next(text, ",", nested, nested[0]) == 1
    text = "abcd"
    nested = u.nest(text)
    assert u.cond_next(text, ",", nested, nested[0]) == 3