github.com/u-root/u-root@v7.0.1-0.20200915234505-ad7babab0a8e+incompatible/cmds/core/elvish/util/subseq_test.go (about) 1 package util 2 3 import "testing" 4 5 var hasSubseqTests = []struct { 6 s, t string 7 want bool 8 }{ 9 {"", "", true}, 10 {"a", "", true}, 11 {"a", "a", true}, 12 {"ab", "a", true}, 13 {"ab", "b", true}, 14 {"abc", "ac", true}, 15 {"abcdefg", "bg", true}, 16 {"abcdefg", "ga", false}, 17 {"foo lorem ipsum", "f l i", true}, 18 {"foo lorem ipsum", "oo o pm", true}, 19 {"你好世界", "好", true}, 20 {"你好世界", "好界", true}, 21 } 22 23 func TestHasSubseq(t *testing.T) { 24 for _, test := range hasSubseqTests { 25 if b := HasSubseq(test.s, test.t); b != test.want { 26 t.Errorf("HasSubseq(%q, %q) = %v, want %v", test.s, test.t, b, test.want) 27 } 28 } 29 }