func TestMatchProcessor(t *testing.T) {
	assert := audit.NewTestingAssertion(t, true)
	tests := []struct {
		pattern string
		in      string
		out     string
		ok      bool
	}{
		{"[0-9]+", "+++12345+++", "+++12345+++", true},
		{"^[0-9]+", "+++12345+++", "+++12345+++", false},
		{"[", "+++12345+++", "error processing '+++12345+++': error parsing regexp: missing closing ]: `[`", false},
	}
	for _, test := range tests {
		matcher := stringex.NewMatchProcessor(test.pattern)
		out, ok := matcher(test.in)
		assert.Equal(ok, test.ok)
		assert.Equal(out, test.out)
	}
}
TestMatchProcessor tests the matching of patterns.
package stringex_test
import (
	"strings"
	"testing"
	"github.com/tideland/golib/audit"
	"github.com/tideland/golib/stringex"
)
func TestWrapping(t *testing.T) {
	assert := audit.NewTestingAssertion(t, true)
	upperCaser := stringex.WrapProcessorFunc(strings.ToUpper)
	value, ok := upperCaser("test")
	assert.True(ok)
	assert.Equal(value, "TEST")
}
func TestSplitMapProcessor(t *testing.T) {
	assert := audit.NewTestingAssertion(t, true)
	sep := "the"
	upperCaser := stringex.WrapProcessorFunc(strings.ToUpper)
	splitMapper := stringex.NewSplitMapProcessor(sep, upperCaser)
	value, ok := splitMapper("the quick brown fox jumps over the lazy dog")
	assert.True(ok)
	assert.Equal(value, "the QUICK BROWN FOX JUMPS OVER the LAZY DOG")
}
func TestSubstringProcessor(t *testing.T) {
	assert := audit.NewTestingAssertion(t, true)
	tests := []struct {
		index  int
		length int
		in     string
		out    string
		ok     bool
	}{
		{0, 5, "yadda", "yadda", true},
		{0, 3, "yadda", "yad", true},
		{2, 3, "yadda", "dda", true},
		{2, 5, "yadda", "dda", true},
		{-1, 5, "yadda", "yadda", true},
		{-1, 10, "yadda", "yadda", true},
		{0, 0, "yadda", "", false},
	}
	for _, test := range tests {
		substringer := stringex.NewSubstringProcessor(test.index, test.length)
		out, ok := substringer(test.in)
		assert.Equal(ok, test.ok)
		assert.Equal(out, test.out)
	}
}