func TestInternalDataTypeStringer(t *testing.T) {
	for _, dt := range []InternalDataType{
		TypeFloat,
		TypeDouble,
		TypeInteger,
		TypeLong,
		TypeString,
		TypeByte,
		TypeBinary,
		TypeDate,
		TypeDateTime,
		TypeDuration,
		TypeIP,
		TypeURL,
		TypePassword,
		TypeComplex,
		TypeBoolean,
		TypeUnsupported,
	} {
		s, ss := dt.String(), datatypes[dt]
		if s != ss {
			t.Errorf("expected %s, got %s", ss, s)
		}
	}
	udt := InternalDataType(255).String()
	if udt != "" {
		t.Errorf("expected invalid data type to have no string representation, got %s", udt)
	}
}
TestInternalDataTypeStringer tests that the internal
data types implements the Stringer interface.
package openapi
import (
	"net"
	"net/url"
	"reflect"
	"testing"
	"time"
	"unsafe"
	"github.com/gofrs/uuid"
	"github.com/stretchr/testify/assert"
)
func TestInternalDataType(t *testing.T) {
	type formatType struct {
		Type   string
		Format string
	}
	tests := map[InternalDataType]formatType{
		TypeFloat:       {"number", "float"},
		TypeDouble:      {"number", "double"},
		TypeInteger:     {"integer", "int32"},
		TypeLong:        {"integer", "int64"},
		TypeString:      {"string", ""},
		TypeByte:        {"string", "byte"},
		TypeBinary:      {"string", "binary"},
		TypeDate:        {"string", "date"},
		TypeDateTime:    {"string", "date-time"},
		TypeDuration:    {"string", "duration"},
		TypeIP:          {"string", "ip"},
		TypeURL:         {"string", "url"},
		TypePassword:    {"string", "password"},
		TypeComplex:     {"string", ""},
		TypeBoolean:     {"boolean", ""},
		TypeUnsupported: {},
	}
	for dt, ft := range tests {
		format, typ := dt.Format(), dt.Type()
		if format != ft.Format {
			t.Errorf("expected format %s for data type %s, got %s", ft.Format, dt.String(), format)
		}
		if typ != ft.Type {
			t.Errorf("expected type %s for data type %s, got %s", ft.Type, dt.String(), typ)
		}
	}
}
func TestPrimitiveGoTypeToDataType(t *testing.T) {
	tests := map[interface{}]DataType{
		int(0):       TypeInteger,
		int8(1):      TypeInteger,
		int16(2):     TypeInteger,
		int32(3):     TypeInteger,
		int64(4):     TypeLong,
		new(int):     TypeInteger,
		new(int64):   TypeLong,
		uint(0):      TypeInteger,
		uint8(1):     TypeInteger,
		uint16(2):    TypeInteger,
		uint32(3):    TypeInteger,
		uint64(4):    TypeLong,
		new(uint):    TypeInteger,
		new(uint64):  TypeLong,
		float32(1.0): TypeFloat,
		float64(2.0): TypeDouble,
		new(float32): TypeFloat,
		new(float64): TypeDouble,
		true:         TypeBoolean,
		false:        TypeBoolean,
		new(bool):    TypeBoolean,
		"string1":    TypeString,
		`string2`:    TypeString,
		new(string):  TypeString,
	}
	for i, dt := range tests {
		tof := reflect.TypeOf(i)
		dtt := DataTypeFromType(tof)
		if dtt != dt {
			t.Errorf("expected data type %s for Go type %s, got %s", dt, tof.String(), dtt)
		}
	}
}
func TestComplexGoTypeToDataType(t *testing.T) {
	tests := map[reflect.Type]InternalDataType{
		rt([]byte{}):                 TypeByte,
		rt(time.Now()):               TypeDateTime,
		rt(5 * time.Second):          TypeDuration,
		rt(url.URL{}):                TypeURL,
		rt(net.IP{}):                 TypeIP,
		rt(struct{}{}):               TypeComplex,
		rt([]string{}):               TypeComplex,
		rt([6]string{}):              TypeComplex,
		rt([...]string{}):            TypeComplex,
		rt(map[string]string{}):      TypeComplex,
		rt(map[int]string{}):         TypeComplex,
		rt(func() {}):                TypeUnsupported,
		rt(make(chan int)):           TypeUnsupported,
		rt(uintptr(0xFEED)):          TypeUnsupported,
		rt(unsafe.Pointer(new(int))): TypeUnsupported,
		rt(complex(1.0, float32(0))): TypeUnsupported,
		rt(complex(2.0, float64(0))): TypeUnsupported,
	}
	for tof, dt := range tests {
		dtt := DataTypeFromType(tof)
		if dtt != dt {
			t.Errorf("expected data type %s for Go type %s, got %s", dt, tof.String(), dtt)
		}
	}
}