func TestAsBool(t *testing.T) {
	assert := audit.NewTestingAssertion(t, true)
	d := stringex.NewDefaulter("AsBool", true)
	tests := []struct {
		v        valuer
		dv       bool
		expected bool
	}{
		{valuer{"1", false}, false, true},
		{valuer{"t", false}, false, true},
		{valuer{"T", false}, false, true},
		{valuer{"TRUE", false}, false, true},
		{valuer{"true", false}, false, true},
		{valuer{"True", false}, false, true},
		{valuer{"wahr", false}, true, true},
		{valuer{"", true}, true, true},
		{valuer{"0", false}, true, false},
		{valuer{"f", false}, true, false},
		{valuer{"F", false}, true, false},
		{valuer{"FALSE", false}, true, false},
		{valuer{"false", false}, true, false},
		{valuer{"False", false}, true, false},
		{valuer{"falsch", false}, false, false},
		{valuer{"", true}, false, false},
	}
	for i, test := range tests {
		assert.Logf("test %v %d: %v and default %v", d, i, test.v, test.dv)
		bv := d.AsBool(test.v, test.dv)
		assert.Equal(bv, test.expected)
	}
}
TestAsBool checks the access of bool values.
package stringex_test
import (
	"errors"
	"math"
	"strconv"
	"testing"
	"time"
	"github.com/tideland/golib/audit"
	"github.com/tideland/golib/stringex"
)
const (
	maxUint = ^uint(0)
	minUint = 0
	maxInt  = int(maxUint >> 1)
	minInt  = -maxInt - 1
)
func TestAsString(t *testing.T) {
	assert := audit.NewTestingAssertion(t, true)
	d := stringex.NewDefaulter("AsString", true)
	tests := []struct {
		v        valuer
		dv       string
		expected string
	}{
		{valuer{"foo", false}, "bar", "foo"},
		{valuer{"foo", true}, "bar", "bar"},
	}
	for i, test := range tests {
		assert.Logf("test %v %d: %v and default %v", d, i, test.v, test.dv)
		sv := d.AsString(test.v, test.dv)
		assert.Equal(sv, test.expected)
	}
}
func TestAsStringSlice(t *testing.T) {
	assert := audit.NewTestingAssertion(t, true)
	d := stringex.NewDefaulter("AsStringSlice", true)
	tests := []struct {
		v        valuer
		sep      string
		dv       []string
		expected []string
	}{
		{valuer{"a/b/c", false}, "/", []string{"a"}, []string{"a", "b", "c"}},
		{valuer{"a/b/c", true}, "/", []string{"a"}, []string{"a"}},
		{valuer{"a/b/c", false}, "/", nil, []string{"a", "b", "c"}},
		{valuer{"a/b/c", true}, "/", nil, nil},
		{valuer{"", false}, "/", nil, []string{""}},
		{valuer{"", true}, "/", []string{"foo"}, []string{"foo"}},
		{valuer{"a/b/c", false}, ":", []string{"a"}, []string{"a/b/c"}},
	}
	for i, test := range tests {
		assert.Logf("test %v %d: %v and default %v", d, i, test.v, test.dv)
		sv := d.AsStringSlice(test.v, test.sep, test.dv)
		assert.Equal(sv, test.expected)
	}
}
func TestAsStringMap(t *testing.T) {
	assert := audit.NewTestingAssertion(t, true)
	d := stringex.NewDefaulter("AsStringMap", true)
	tests := []struct {
		v        valuer
		rsep     string
		kvsep    string
		dv       map[string]string
		expected map[string]string
	}{
		{valuer{"a:1/b:2", false}, "/", ":", map[string]string{"a": "1"}, map[string]string{"a": "1", "b": "2"}},
		{valuer{"a:1/b:2", true}, "/", ":", map[string]string{"a": "1"}, map[string]string{"a": "1"}},
		{valuer{"a:1/b:2", false}, "/", ":", nil, map[string]string{"a": "1", "b": "2"}},
		{valuer{"a:1/b:2", true}, "/", ":", nil, nil},
		{valuer{"", false}, "/", ":", nil, map[string]string{"": ""}},
		{valuer{"", true}, "/", ":", map[string]string{"a": "1"}, map[string]string{"a": "1"}},
		{valuer{"a:1/b:2", false}, "|", "=", nil, map[string]string{"a:1/b:2": "a:1/b:2"}},
	}
	for i, test := range tests {
		assert.Logf("test %v %d: %v and default %v", d, i, test.v, test.dv)
		sv := d.AsStringMap(test.v, test.rsep, test.kvsep, test.dv)
		assert.Equal(sv, test.expected)
	}
}