forked from Silverfish/proton-bridge
GODT-1650: text/html sending tests
This commit is contained in:
@ -1,11 +1,27 @@
|
||||
package tests
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"reflect"
|
||||
|
||||
"github.com/bradenaw/juniper/xslices"
|
||||
)
|
||||
|
||||
func ToAny(v any) any {
|
||||
b, err := json.Marshal(v)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
var a any
|
||||
|
||||
if err := json.Unmarshal(b, &a); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
return a
|
||||
}
|
||||
|
||||
func IsSub(outer, inner any) bool {
|
||||
if outer == nil && inner != nil {
|
||||
return IsSub(reflect.Zero(reflect.TypeOf(inner)).Interface(), inner)
|
||||
@ -30,10 +46,6 @@ func IsSub(outer, inner any) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
if len(inner) != len(outer) {
|
||||
return false
|
||||
}
|
||||
|
||||
return isSubSlice(outer, inner)
|
||||
|
||||
default:
|
||||
@ -69,6 +81,10 @@ func isSubMap(outer, inner map[string]any) bool {
|
||||
}
|
||||
|
||||
func isSubSlice(outer, inner []any) bool {
|
||||
if len(inner) != len(outer) {
|
||||
return false
|
||||
}
|
||||
|
||||
for _, v := range inner {
|
||||
if xslices.IndexFunc(outer, func(outer any) bool {
|
||||
return IsSub(outer, v)
|
||||
|
||||
Reference in New Issue
Block a user