Jump to content

Module talk:String/testcases

Add topic
From mediawiki.org

All tests passed.

test_find:

Text Expected Actual
Yes {{#invoke:String|find|}} 0 0
Yes {{#invoke:String|find|source=}} 0 0
Yes {{#invoke:String|find|source=|target=}} 0 0
Yes {{#invoke:String|find|source=|target=Bob}} 0 0
Yes {{#invoke:String|find|Bob|Joe}} 0 0
Yes {{#invoke:String|find|Bob|b}} 3 3
Yes {{#invoke:String|find|Bob Joe|oe}} 6 6
Yes {{#invoke:String|find|source= Bob |o}} 2 2
Yes {{#invoke:String|find| Bob |o}} 3 3
Yes {{#invoke:String|find|높지만 급격히|만}} 3 3
Yes {{#invoke:String|find|source=BAAAB|target=%w|plain=false}} 1 1
Yes {{#invoke:String|find|source=BAAAB|target=%w|start=3|plain=false}} 3 3
Yes {{#invoke:String|find|source=BAAAB|target=(%w)%1|plain=false}} 2 2

test_len:

Text Expected Actual
Yes {{#invoke:String|len| foo }} 5 5
Yes {{#invoke:String|len|s= foo }} 3 3
Yes {{#invoke:String|len|}} 0 0
Yes {{#invoke:String|len|s=}} 0 0
Yes {{#invoke:String|len| }} 3 3
Yes {{#invoke:String|len|最近の更新}} 5 5

test_match:

Text Expected Actual
Yes {{#invoke:String|match|dog (cat)|%((%a-)%)}} cat cat
Yes {{#invoke:String|match|dog (cat) (canary) (fish)|%((%a-)%)||-1}} fish fish
Yes {{#invoke:String|match|dog (cat) (canary) (fish)|%((%a-)%)||2}} canary canary
Yes {{#invoke:String|match|dog (cat) (canary) (fish)|%((%a-)%)|6|1}} canary canary
Yes {{#invoke:String|match|dog (cat) (canary) (fish)|%((%a-)%)|6|2}} fish fish
Yes {{#invoke:String|match|dog (cat)|%((%a-)%)||2|no_category=true}} String Module Error: Match not found String Module Error: Match not found
Yes {{#invoke:String|match|dog (cat)|%((%a-)%)||2|ignore_errors=true}}

test_rep:

Text Expected Actual
Yes {{#invoke:String|rep|abc|1}} abc abc
Yes {{#invoke:String|rep|a b|7}} a ba ba ba ba ba ba b a ba ba ba ba ba ba b
Yes {{#invoke:String|rep|bla|glug|no_category=true}} String Module Error: function rep expects a number as second parameter, received "glug" String Module Error: function rep expects a number as second parameter, received "glug"
Yes {{#invoke:String|rep|bla|glug|ignore_errors=true}}
Yes {{#invoke:String|rep|àèò|3}} àèòàèòàèò àèòàèòàèò

test_replace:

Text Expected Actual
Yes {{#invoke:String|replace|1.1.1.1|.|/}} 1/1/1/1 1/1/1/1
Yes {{#invoke:String|replace|alpha (beta)| (| gamma (}} alpha gamma (beta) alpha gamma (beta)
Yes {{#invoke:String|replace|Dog (cat)|%s%(.*%)||plain=false}} Dog Dog

Start a discussion about Module:String/testcases

Start a discussion