File: subseq_test.go

package info (click to toggle)
elvish 0.21.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 6,372 kB
  • sloc: javascript: 236; sh: 130; python: 104; makefile: 88; xml: 9
file content (29 lines) | stat: -rw-r--r-- 623 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
package strutil

import "testing"

var hasSubseqTests = []struct {
	s, t string
	want bool
}{
	{"", "", true},
	{"a", "", true},
	{"a", "a", true},
	{"ab", "a", true},
	{"ab", "b", true},
	{"abc", "ac", true},
	{"abcdefg", "bg", true},
	{"abcdefg", "ga", false},
	{"foo lorem ipsum", "f l i", true},
	{"foo lorem ipsum", "oo o pm", true},
	{"你好世界", "好", true},
	{"你好世界", "好界", true},
}

func TestHasSubseq(t *testing.T) {
	for _, test := range hasSubseqTests {
		if b := HasSubseq(test.s, test.t); b != test.want {
			t.Errorf("HasSubseq(%q, %q) = %v, want %v", test.s, test.t, b, test.want)
		}
	}
}