literal: add test suite

This commit is contained in:
Michael Muré
2024-11-06 16:42:45 +01:00
parent 41b8600fbc
commit 8447499c5a
2 changed files with 138 additions and 1 deletions

View File

@@ -68,7 +68,19 @@ func anyAssemble(val any) qp.Assemble {
}
switch rt.Kind() {
case reflect.Array, reflect.Slice:
case reflect.Array:
if rt.Elem().Kind() == reflect.Uint8 {
panic("bytes array are not supported yet")
}
return qp.List(int64(rv.Len()), func(la datamodel.ListAssembler) {
for i := range rv.Len() {
qp.ListEntry(la, anyAssemble(rv.Index(i)))
}
})
case reflect.Slice:
if rt.Elem().Kind() == reflect.Uint8 {
return qp.Bytes(val.([]byte))
}
return qp.List(int64(rv.Len()), func(la datamodel.ListAssembler) {
for i := range rv.Len() {
qp.ListEntry(la, anyAssemble(rv.Index(i)))