class test repeat pattern
repeat pattern[character] make pattern(boolean do match empty)
return repeat pattern[character] • new(sequence pattern[character] • new(patterns list), do match empty)
testcase test match()
assert the pattern("")
assert the pattern("abc")
assert the pattern("AC")
assert the pattern("AaaCcc")
assert the pattern("AaaBBBCcc")
assert the pattern("abcabc")
assert the pattern("ACacABC")
assert !the pattern("bac")
assert !the pattern("aabb")
assert !the pattern("aaca")
assert !the pattern("aacabbbca")
testcase test viable prefix()
assert the pattern • is viable prefix("")
assert the pattern • is viable prefix("a")
assert the pattern • is viable prefix("aAa")
assert the pattern • is viable prefix("aabb")
assert the pattern • is viable prefix("aacc")
assert the pattern • is viable prefix("aaBcc")
assert the pattern • is viable prefix("abcacab")
assert the pattern • is viable prefix("abbccaa")
assert the pattern • is viable prefix("ABCACAC")
assert !the pattern • is viable prefix("x")
assert !the pattern • is viable prefix("xyz")
assert !the pattern • is viable prefix("bbb")
assert !the pattern • is viable prefix("bcc")
assert !the pattern • is viable prefix("Ccc")
assert !the pattern • is viable prefix("Abcabcb")
testcase test match prefix()
assert the pattern • match prefix("abc") == 3
assert the pattern • match prefix("abcdef") == 3
assert the pattern • match prefix("aAbBcCdef") == 6
assert the pattern • match prefix("aAbCdef") == 4
assert the pattern • match prefix("aaabbbcccddd") == 9
assert the pattern • match prefix("abcacaxyz") == 5
assert the pattern • match prefix("ACACABCfoo") == 7
assert the pattern • match prefix("ACfoo") == 2
assert the pattern2 • match prefix("") == 0
assert the pattern2 • match prefix("a") == 0
assert the pattern2 • match prefix("ab") == 0
assert the pattern2 • match prefix("x") == 0
assert the pattern2 • match prefix("xabc") == 0
assert the pattern2 • match prefix("abc") == 3
assert the pattern2 • match prefix("abcdef") == 3
assert the pattern2 • match prefix("aAbBcCdef") == 6
assert the pattern2 • match prefix("aAbCdef") == 4
assert the pattern2 • match prefix("aaabbbcccddd") == 9
assert the pattern2 • match prefix("abcacaxyz") == 5
assert the pattern2 • match prefix("ACACABCfoo") == 7
assert the pattern2 • match prefix("ACfoo") == 2
testcase test find first()
assert match is_not null
assert match • begin == 2
assert match • end == 8
assert match2 is_not null
assert match2 • begin == 2
assert match2 • end == 15
assert match3 is_not null
assert match3 • begin == 3
assert match3 • end == 8
assert match4 is_not null
assert match4 • begin == 9
assert match4 • end == 15
testcase test split()
assert split0 • size == 1
assert equals(split0[0], "foo")
assert split1 • size == 3
assert equals(split1[0], "foo")
assert equals(split1[1], "xyz")
assert equals(split1[2], "")
assert split2 • size == 4
assert equals(split2[0], "")
assert equals(split2[1], "1")
assert equals(split2[2], "2")
assert equals(split2[3], "3")