increased test coverage and splitted some utility functions by OS
This commit is contained in:
@@ -164,3 +164,48 @@ func TestCopyMap(t *testing.T) {
|
||||
t.Errorf("utils.CopyMap() failed")
|
||||
}
|
||||
}
|
||||
|
||||
func TestToStringOk(t *testing.T) {
|
||||
source := "ciao"
|
||||
wantValue := "ciao"
|
||||
wantErr := error(nil)
|
||||
|
||||
gotValue, gotErr := ToGoString(source, "test")
|
||||
|
||||
if gotErr != nil {
|
||||
t.Error(gotErr)
|
||||
} else if gotValue != wantValue {
|
||||
t.Errorf("toGoString(%v, \"test\") gotValue=%v, gotErr=%v -> wantValue=%v, wantErr=%v",
|
||||
source, gotValue, gotErr, wantValue, wantErr)
|
||||
}
|
||||
}
|
||||
|
||||
func TestToStringErr(t *testing.T) {
|
||||
source := newListA()
|
||||
wantValue := ""
|
||||
wantErr := errors.New(`test expected string, got list ([])`)
|
||||
|
||||
gotValue, gotErr := ToGoString(source, "test")
|
||||
|
||||
if gotErr != nil && gotErr.Error() != wantErr.Error() {
|
||||
t.Errorf(`ToGoString(%v, "test") gotValue=%q, gotErr=%v -> wantValue=%q, wantErr=%v`,
|
||||
source, gotValue, gotErr, wantValue, wantErr)
|
||||
} else if gotValue != wantValue {
|
||||
t.Errorf(`ToString(%v, "test") gotValue=%q, gotErr=%v -> wantValue=%q, wantErr=%v`,
|
||||
source, gotValue, gotErr, wantValue, wantErr)
|
||||
}
|
||||
}
|
||||
|
||||
func TestIsFunctorSucc(t *testing.T) {
|
||||
f := NewGolangFunctor(isNilFunc)
|
||||
if !isFunctor(f) {
|
||||
t.Errorf("isNilFunc() evalued as not a functor")
|
||||
}
|
||||
}
|
||||
|
||||
func TestIsFunctorFail(t *testing.T) {
|
||||
f := int64(1)
|
||||
if isFunctor(f) {
|
||||
t.Errorf("int evalued as a functor")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user