test: cover builtin types

This commit is contained in:
Adrien Marquès 2021-06-20 21:52:43 +02:00
parent 461c17299e
commit f17622195a
6 changed files with 78 additions and 0 deletions

View File

@ -2,11 +2,24 @@ package validator_test
import (
"fmt"
"reflect"
"testing"
"github.com/xdrm-io/aicra/validator"
)
func TestAny_ReflectType(t *testing.T) {
t.Parallel()
var (
dt = validator.AnyType{}
expected = reflect.TypeOf(interface{}(nil))
)
if dt.GoType() != expected {
t.Fatalf("invalid GoType() %v ; expected %v", dt.GoType(), expected)
}
}
func TestAny_AvailableTypes(t *testing.T) {
t.Parallel()

View File

@ -2,11 +2,24 @@ package validator_test
import (
"fmt"
"reflect"
"testing"
"github.com/xdrm-io/aicra/validator"
)
func TestBool_ReflectType(t *testing.T) {
t.Parallel()
var (
dt = validator.BoolType{}
expected = reflect.TypeOf(true)
)
if dt.GoType() != expected {
t.Fatalf("invalid GoType() %v ; expected %v", dt.GoType(), expected)
}
}
func TestBool_AvailableTypes(t *testing.T) {
t.Parallel()

View File

@ -3,11 +3,24 @@ package validator_test
import (
"fmt"
"math"
"reflect"
"testing"
"github.com/xdrm-io/aicra/validator"
)
func TestFloat64_ReflectType(t *testing.T) {
t.Parallel()
var (
dt = validator.FloatType{}
expected = reflect.TypeOf(float64(0.0))
)
if dt.GoType() != expected {
t.Fatalf("invalid GoType() %v ; expected %v", dt.GoType(), expected)
}
}
func TestFloat64_AvailableTypes(t *testing.T) {
t.Parallel()

View File

@ -3,11 +3,24 @@ package validator_test
import (
"fmt"
"math"
"reflect"
"testing"
"github.com/xdrm-io/aicra/validator"
)
func TestInt_ReflectType(t *testing.T) {
t.Parallel()
var (
dt = validator.IntType{}
expected = reflect.TypeOf(int(0))
)
if dt.GoType() != expected {
t.Fatalf("invalid GoType() %v ; expected %v", dt.GoType(), expected)
}
}
func TestInt_AvailableTypes(t *testing.T) {
t.Parallel()

View File

@ -2,11 +2,24 @@ package validator_test
import (
"fmt"
"reflect"
"testing"
"github.com/xdrm-io/aicra/validator"
)
func TestString_ReflectType(t *testing.T) {
t.Parallel()
var (
dt = validator.StringType{}
expected = reflect.TypeOf(string("abc"))
)
if dt.GoType() != expected {
t.Fatalf("invalid GoType() %v ; expected %v", dt.GoType(), expected)
}
}
func TestString_AvailableTypes(t *testing.T) {
t.Parallel()

View File

@ -3,11 +3,24 @@ package validator_test
import (
"fmt"
"math"
"reflect"
"testing"
"github.com/xdrm-io/aicra/validator"
)
func TestUint_ReflectType(t *testing.T) {
t.Parallel()
var (
dt = validator.UintType{}
expected = reflect.TypeOf(uint(0))
)
if dt.GoType() != expected {
t.Fatalf("invalid GoType() %v ; expected %v", dt.GoType(), expected)
}
}
func TestUint_AvailableTypes(t *testing.T) {
t.Parallel()