Exemplo n.º 1
0
func TestEqual(t *testing.T) {
	defer clearPatternCache()
	clearPatternCache()
	pattern := BuildPattern(true, true, CaseSmart, true, []Range{}, Delimiter{}, []rune("^AbC$"))

	match := func(str string, sidxExpected int32, eidxExpected int32) {
		res := algo.EqualMatch(
			pattern.caseSensitive, pattern.forward, []rune(str), pattern.termSets[0][0].text)
		if res.Start != sidxExpected || res.End != eidxExpected {
			t.Errorf("%s / %d / %d", pattern.termSets, res.Start, res.End)
		}
	}
	match("ABC", -1, -1)
	match("AbC", 0, 3)
}
Exemplo n.º 2
0
func TestEqual(t *testing.T) {
	defer clearPatternCache()
	clearPatternCache()
	pattern := BuildPattern(ModeExtended, CaseSmart, []Range{}, nil, []rune("^AbC$"))

	match := func(str string, sidxExpected int, eidxExpected int) {
		sidx, eidx := algo.EqualMatch(
			pattern.caseSensitive, []rune(str), pattern.terms[0].text)
		if sidx != sidxExpected || eidx != eidxExpected {
			t.Errorf("%s / %d / %d", pattern.terms, sidx, eidx)
		}
	}
	match("ABC", -1, -1)
	match("AbC", 0, 3)
}
Exemplo n.º 3
0
func TestEqual(t *testing.T) {
	defer clearPatternCache()
	clearPatternCache()
	pattern := BuildPattern(true, algo.FuzzyMatchV2, true, CaseSmart, true, true, []Range{}, Delimiter{}, []rune("^AbC$"))

	match := func(str string, sidxExpected int, eidxExpected int) {
		res, pos := algo.EqualMatch(
			pattern.caseSensitive, pattern.forward, util.RunesToChars([]rune(str)), pattern.termSets[0][0].text, true, nil)
		if res.Start != sidxExpected || res.End != eidxExpected {
			t.Errorf("%s / %d / %d", pattern.termSets, res.Start, res.End)
		}
		if pos != nil {
			t.Errorf("pos is expected to be nil")
		}
	}
	match("ABC", -1, -1)
	match("AbC", 0, 3)
}