parent
21cbfbaabb
commit
cc0ffd88f6
@ -0,0 +1,102 @@
|
|||||||
|
/* ——————————————————————————————————————————————————————————————————————————
|
||||||
|
Proyecto WIAWAIW
|
||||||
|
—————————————————————————————————————————————————————————————————————————————
|
||||||
|
Fichero a.go
|
||||||
|
Package cval
|
||||||
|
Autor Juan V. Navarro juanvnl@activething.com
|
||||||
|
Creado 07/09/2025
|
||||||
|
—————————————————————————————————————————————————————————————————————————————
|
||||||
|
|
||||||
|
LICENSES AND TERMS OF USE
|
||||||
|
-------------------------
|
||||||
|
|
||||||
|
This software is licensed under the Elastic License v2.0 (the "License").
|
||||||
|
For full terms and additional information regarding permitted and prohibited
|
||||||
|
uses, please visit:
|
||||||
|
https://activething.com/wiawiaw/licenses
|
||||||
|
|
||||||
|
You may use, copy, modify, and redistribute this software internally within
|
||||||
|
your organization for any purpose, including research, development, and
|
||||||
|
testing, subject to the terms of this License.
|
||||||
|
|
||||||
|
You may NOT, however, use, provide, distribute, or make this software
|
||||||
|
available to any third party as part of a hosted service, SaaS offering, or
|
||||||
|
commercial product without first obtaining a commercial license from
|
||||||
|
Active Thing.
|
||||||
|
|
||||||
|
You may combine this software with other code, provided that such
|
||||||
|
combination does not circumvent the restrictions of this License.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT. In no event shall
|
||||||
|
the authors or copyright holders be liable for any claim, damages, or other
|
||||||
|
liability arising from the use of this software.
|
||||||
|
|
||||||
|
—————————————————————————————————————————————————————————————————————————————
|
||||||
|
|
||||||
|
Web : activething.com | wiawiaw.com
|
||||||
|
git : g.activething.com | github.com/activething
|
||||||
|
Correo : dev@activething.com
|
||||||
|
|
||||||
|
—————————————————————————————————————————————————————————————————————————————
|
||||||
|
No deseo caminar sobre el agua", dijo Siddhartha.
|
||||||
|
Que los antiguos chamanes se contenten con tales habilidades.
|
||||||
|
—— Hermann Hesse, Siddhartha
|
||||||
|
—————————————————————————————————————————————————————————————————————————————
|
||||||
|
Copyright (c) 2025 Active Thing
|
||||||
|
————————————————————————————————————————————————————————————————————————————— */
|
||||||
|
|
||||||
|
package cval
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
var (
|
||||||
|
|
||||||
|
ckindNames = []string {
|
||||||
|
"invalid",
|
||||||
|
"any",
|
||||||
|
"bool",
|
||||||
|
"int",
|
||||||
|
"int8",
|
||||||
|
"int16",
|
||||||
|
"int32",
|
||||||
|
"int64",
|
||||||
|
"uint",
|
||||||
|
"uint8",
|
||||||
|
"uint16",
|
||||||
|
"uint32",
|
||||||
|
"uint64",
|
||||||
|
"uintptr",
|
||||||
|
"duration",
|
||||||
|
"float32",
|
||||||
|
"float64",
|
||||||
|
"complex64",
|
||||||
|
"complex128",
|
||||||
|
"bigInt",
|
||||||
|
"hashAlg",
|
||||||
|
"string",
|
||||||
|
"uUID",
|
||||||
|
"bytes",
|
||||||
|
"stack",
|
||||||
|
"date",
|
||||||
|
"cValue",
|
||||||
|
"reflect",
|
||||||
|
"object",
|
||||||
|
"packable",
|
||||||
|
"context",
|
||||||
|
"stringer",
|
||||||
|
"error",
|
||||||
|
}
|
||||||
|
|
||||||
|
ctypeNames = []string{
|
||||||
|
"",
|
||||||
|
"defer",
|
||||||
|
"list",
|
||||||
|
"map",
|
||||||
|
}
|
||||||
|
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -0,0 +1,110 @@
|
|||||||
|
/* ——————————————————————————————————————————————————————————————————————————
|
||||||
|
Proyecto WIAWAIW
|
||||||
|
—————————————————————————————————————————————————————————————————————————————
|
||||||
|
Fichero ckind.go
|
||||||
|
Package cval
|
||||||
|
Autor Juan V. Navarro juanvnl@activething.com
|
||||||
|
Creado 06/09/2025
|
||||||
|
—————————————————————————————————————————————————————————————————————————————
|
||||||
|
|
||||||
|
LICENSES AND TERMS OF USE
|
||||||
|
-------------------------
|
||||||
|
|
||||||
|
This software is licensed under the Elastic License v2.0 (the "License").
|
||||||
|
For full terms and additional information regarding permitted and prohibited
|
||||||
|
uses, please visit:
|
||||||
|
https://activething.com/wiawiaw/licenses
|
||||||
|
|
||||||
|
You may use, copy, modify, and redistribute this software internally within
|
||||||
|
your organization for any purpose, including research, development, and
|
||||||
|
testing, subject to the terms of this License.
|
||||||
|
|
||||||
|
You may NOT, however, use, provide, distribute, or make this software
|
||||||
|
available to any third party as part of a hosted service, SaaS offering, or
|
||||||
|
commercial product without first obtaining a commercial license from
|
||||||
|
Active Thing.
|
||||||
|
|
||||||
|
You may combine this software with other code, provided that such
|
||||||
|
combination does not circumvent the restrictions of this License.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT. In no event shall
|
||||||
|
the authors or copyright holders be liable for any claim, damages, or other
|
||||||
|
liability arising from the use of this software.
|
||||||
|
|
||||||
|
—————————————————————————————————————————————————————————————————————————————
|
||||||
|
|
||||||
|
Web : activething.com | wiawiaw.com
|
||||||
|
git : g.activething.com | github.com/activething
|
||||||
|
Correo : dev@activething.com
|
||||||
|
|
||||||
|
—————————————————————————————————————————————————————————————————————————————
|
||||||
|
No deseo caminar sobre el agua", dijo Siddhartha.
|
||||||
|
Que los antiguos chamanes se contenten con tales habilidades.
|
||||||
|
—— Hermann Hesse, Siddhartha
|
||||||
|
—————————————————————————————————————————————————————————————————————————————
|
||||||
|
Copyright (c) 2025 Active Thing
|
||||||
|
————————————————————————————————————————————————————————————————————————————— */
|
||||||
|
|
||||||
|
package cval
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
const (
|
||||||
|
// Tipos de valor/clave (hasta 64 valores)
|
||||||
|
|
||||||
|
CKindInvalid CKind = iota
|
||||||
|
CKindAny
|
||||||
|
CKindBool
|
||||||
|
CKindInt
|
||||||
|
CKindInt8
|
||||||
|
CKindInt16
|
||||||
|
CKindInt32
|
||||||
|
CKindInt64
|
||||||
|
CKindUint
|
||||||
|
CKindUint8
|
||||||
|
CKindUint16
|
||||||
|
CKindUint32
|
||||||
|
CKindUint64
|
||||||
|
CKindUintptr
|
||||||
|
CKindDuration
|
||||||
|
CKindFloat32
|
||||||
|
CKindFloat64
|
||||||
|
CKindComplex64
|
||||||
|
CKindComplex128
|
||||||
|
CKindBigInt
|
||||||
|
CKindHashAlg
|
||||||
|
CKindString
|
||||||
|
CKindUUID
|
||||||
|
CKindBytes
|
||||||
|
CKindStack
|
||||||
|
CKindDate
|
||||||
|
CKindCValue
|
||||||
|
CKindReflect
|
||||||
|
CKindObject
|
||||||
|
CKindPackable
|
||||||
|
CKindContext
|
||||||
|
CKindStringer
|
||||||
|
CKindError
|
||||||
|
|
||||||
|
maxCKind // Límite superior (no usar directamente)
|
||||||
|
|
||||||
|
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
type CKind uint16 // uint16 para soportar valores desplazados (0x0040, 0x0080, 0x00C0)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
func (t CKind) String() string {
|
||||||
|
if t < maxCKind {
|
||||||
|
return ckindNames[t]
|
||||||
|
}
|
||||||
|
return ckindNames[0]
|
||||||
|
}
|
||||||
@ -1,7 +1,7 @@
|
|||||||
/* ——————————————————————————————————————————————————————————————————————————
|
/* ——————————————————————————————————————————————————————————————————————————
|
||||||
Proyecto WIAWAIW
|
Proyecto WIAWAIW
|
||||||
—————————————————————————————————————————————————————————————————————————————
|
—————————————————————————————————————————————————————————————————————————————
|
||||||
Fichero cvalue_state.go
|
Fichero cstate.go
|
||||||
Package cval
|
Package cval
|
||||||
Autor Juan V. Navarro juanvnl@activething.com
|
Autor Juan V. Navarro juanvnl@activething.com
|
||||||
Creado 05/09/2025
|
Creado 05/09/2025
|
||||||
@ -1,170 +0,0 @@
|
|||||||
/* ——————————————————————————————————————————————————————————————————————————
|
|
||||||
Proyecto WIAWAIW
|
|
||||||
—————————————————————————————————————————————————————————————————————————————
|
|
||||||
Fichero cvalue_spec.go
|
|
||||||
Package cval
|
|
||||||
Autor Juan V. Navarro juanvnl@activething.com
|
|
||||||
Creado 05/09/2025
|
|
||||||
—————————————————————————————————————————————————————————————————————————————
|
|
||||||
|
|
||||||
LICENSES AND TERMS OF USE
|
|
||||||
-------------------------
|
|
||||||
|
|
||||||
This software is licensed under the Elastic License v2.0 (the "License").
|
|
||||||
For full terms and additional information regarding permitted and prohibited
|
|
||||||
uses, please visit:
|
|
||||||
https://activething.com/wiawiaw/licenses
|
|
||||||
|
|
||||||
You may use, copy, modify, and redistribute this software internally within
|
|
||||||
your organization for any purpose, including research, development, and
|
|
||||||
testing, subject to the terms of this License.
|
|
||||||
|
|
||||||
You may NOT, however, use, provide, distribute, or make this software
|
|
||||||
available to any third party as part of a hosted service, SaaS offering, or
|
|
||||||
commercial product without first obtaining a commercial license from
|
|
||||||
Active Thing.
|
|
||||||
|
|
||||||
You may combine this software with other code, provided that such
|
|
||||||
combination does not circumvent the restrictions of this License.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT. In no event shall
|
|
||||||
the authors or copyright holders be liable for any claim, damages, or other
|
|
||||||
liability arising from the use of this software.
|
|
||||||
|
|
||||||
—————————————————————————————————————————————————————————————————————————————
|
|
||||||
|
|
||||||
Web : activething.com | wiawiaw.com
|
|
||||||
git : g.activething.com | github.com/activething
|
|
||||||
Correo : dev@activething.com
|
|
||||||
|
|
||||||
—————————————————————————————————————————————————————————————————————————————
|
|
||||||
No deseo caminar sobre el agua", dijo Siddhartha.
|
|
||||||
Que los antiguos chamanes se contenten con tales habilidades.
|
|
||||||
—— Hermann Hesse, Siddhartha
|
|
||||||
—————————————————————————————————————————————————————————————————————————————
|
|
||||||
Copyright (c) 2025 Active Thing
|
|
||||||
————————————————————————————————————————————————————————————————————————————— */
|
|
||||||
|
|
||||||
package cval
|
|
||||||
|
|
||||||
|
|
||||||
const (
|
|
||||||
typeSimpleMaxBits = 6
|
|
||||||
typeCompoundMaxBits = 2
|
|
||||||
|
|
||||||
// Máscaras para extraer los bits en CValueSpec
|
|
||||||
valueTypeMask CValueSpec = 0x003F // 6 bits (0-5)
|
|
||||||
compTypeMask CValueSpec = 0x00C0 // 2 bits (6-7)
|
|
||||||
keyTypeMask CValueSpec = 0x3F00 // 6 bits (8-13)
|
|
||||||
|
|
||||||
// Desplazamientos (solo para creación, no para lectura)
|
|
||||||
compoundTypeShift = typeSimpleMaxBits
|
|
||||||
valueTypeShift = 0
|
|
||||||
keyTypeShift = compoundTypeShift + typeCompoundMaxBits
|
|
||||||
|
|
||||||
// Constantes predefinidas para tipos agregados (alineadas con bits 6-7)
|
|
||||||
compoundNone CValueSpec = 0x0000 // 00 << 6
|
|
||||||
compoundDefer = CValueSpec(1) << compoundTypeShift // 01 << 6 = 0x0040
|
|
||||||
compoundList = CValueSpec(2) << compoundTypeShift // 10 << 6 = 0x0080
|
|
||||||
compoundMap = CValueSpec(3) << compoundTypeShift // 11 << 6 = 0x00C0
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
type CValueSpec uint16
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Funciones de creación
|
|
||||||
|
|
||||||
func MakeCValue(ctyp CType) CValueSpec {
|
|
||||||
return CValueSpec(ctyp) & valueTypeMask
|
|
||||||
}
|
|
||||||
|
|
||||||
func MakeCList(ctyp CType) CValueSpec {
|
|
||||||
return (CValueSpec(ctyp) & valueTypeMask) | compoundList
|
|
||||||
}
|
|
||||||
|
|
||||||
func MakeCMap(ctyp, ktyp CType) CValueSpec {
|
|
||||||
return (CValueSpec(ctyp) & valueTypeMask) | ((CValueSpec(ktyp) & valueTypeMask) << keyTypeShift) | compoundMap
|
|
||||||
}
|
|
||||||
|
|
||||||
func MakeCDeferred(ctyp CType) CValueSpec {
|
|
||||||
return (CValueSpec(ctyp) & valueTypeMask) | compoundDefer
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Métodos para CValueSpec
|
|
||||||
|
|
||||||
func (t CValueSpec) ValueType () CType {
|
|
||||||
// Extrae value type (bits 0-5) con máscara, sin desplazamiento
|
|
||||||
return CType(t & valueTypeMask)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (t CValueSpec) KeyType () CType {
|
|
||||||
// Extrae key type (bits 8-13) con máscara, sin desplazamiento
|
|
||||||
return CType((t & keyTypeMask) >> keyTypeShift)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (t CValueSpec) CompoundType() CType {
|
|
||||||
// Extrae tipo agregado (bits 6-7) con máscara, sin desplazamiento
|
|
||||||
return CType(t & compTypeMask)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (t CValueSpec) IsDefer () bool { return (t & compTypeMask) == CValueSpec(TypeDefer) }
|
|
||||||
|
|
||||||
func (t CValueSpec) IsMap () bool { return (t & compTypeMask) == CValueSpec(TypeMap) }
|
|
||||||
|
|
||||||
func (t CValueSpec) IsList () bool { return (t & compTypeMask) == CValueSpec(TypeList) }
|
|
||||||
|
|
||||||
|
|
||||||
func (t CValueSpec) IsValid() bool {
|
|
||||||
valueType := CType(t & valueTypeMask)
|
|
||||||
// Rechaza TypeInvalid y tipos fuera de rango
|
|
||||||
if valueType == TypeInvalid || valueType >= maxValueType {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
switch CType(t & compTypeMask) {
|
|
||||||
case TypeSimple, TypeDefer, TypeList:
|
|
||||||
// Para estos tipos, los bits de key (8-13) deben ser 0
|
|
||||||
return t&keyTypeMask == 0
|
|
||||||
|
|
||||||
case TypeMap:
|
|
||||||
// Para Map, necesita un keyType válido
|
|
||||||
keyType := CType((t & keyTypeMask) >> keyTypeShift)
|
|
||||||
return keyType != TypeInvalid && keyType < maxValueType
|
|
||||||
|
|
||||||
default:
|
|
||||||
// Tipo agregado inválido
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (t CValueSpec) IsValid2() bool {
|
|
||||||
valueType := CType(t & valueTypeMask) // Bits 0-5, sin desplazamiento
|
|
||||||
if valueType == TypeInvalid { // Rechaza TypeInvalid explícitamente
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
compType := CType(t & compTypeMask) // Bits 6-7, sin desplazamiento
|
|
||||||
if compType == TypeSimple {
|
|
||||||
// Para TypeSimple, los bits 8-13 deben ser 0
|
|
||||||
return valueType < maxValueType && t&keyTypeMask == 0
|
|
||||||
}
|
|
||||||
if compType == TypeMap {
|
|
||||||
keyType := t.KeyType() >> keyTypeShift // Desplazamiento solo para validación
|
|
||||||
return valueType < maxValueType && keyType != TypeInvalid && keyType < maxValueType
|
|
||||||
}
|
|
||||||
// Para TypeDefer y TypeList, los bits 8-13 deben ser 0
|
|
||||||
return valueType < maxValueType && (compType == TypeDefer || compType == TypeList) && t&keyTypeMask == 0
|
|
||||||
}
|
|
||||||
|
|
||||||
func (t CValueSpec) Sanitize() CValueSpec {
|
|
||||||
if !t.IsValid() {
|
|
||||||
return CValueSpec(TypeInvalid)
|
|
||||||
}
|
|
||||||
return t
|
|
||||||
}
|
|
||||||
|
|
||||||
@ -0,0 +1,747 @@
|
|||||||
|
package cval
|
||||||
|
|
||||||
|
import (
|
||||||
|
"testing"
|
||||||
|
)
|
||||||
|
|
||||||
|
// TestMakeCType verifica la función MakeCType
|
||||||
|
func TestMakeCType(t *testing.T) {
|
||||||
|
tests := []struct {
|
||||||
|
name string
|
||||||
|
ctyp CKind
|
||||||
|
expected CType
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
name: "ValidTypeString",
|
||||||
|
ctyp: CKindString,
|
||||||
|
expected: CType(CKindString),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "ValidTypeInt",
|
||||||
|
ctyp: CKindInt,
|
||||||
|
expected: CType(CKindInt),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "InvalidType",
|
||||||
|
ctyp: CKindInvalid,
|
||||||
|
expected: CType(CKindInvalid),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "OutOfRangeType",
|
||||||
|
ctyp: maxCKind,
|
||||||
|
expected: CType(CKindInvalid),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "ArbitraryInvalidType",
|
||||||
|
ctyp: CKind(0xFFFF),
|
||||||
|
expected: CType(CKindInvalid),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "AggregateTypeAsInput",
|
||||||
|
ctyp: CKindCValue,
|
||||||
|
expected: CType(CKindCValue),
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, tt := range tests {
|
||||||
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
|
result := MakeCType(tt.ctyp)
|
||||||
|
if result != tt.expected {
|
||||||
|
t.Errorf("MakeCType(%v): expected %v (0x%04x), got %v (0x%04x)", tt.ctyp, tt.expected, tt.expected, result, result)
|
||||||
|
}
|
||||||
|
if result&0xC000 != 0 {
|
||||||
|
t.Errorf("MakeCType(%v): bits 14-15 should be 0, got %v (0x%04x)", tt.ctyp, result, result)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// TestMakeCTypeList verifica la función MakeCTypeList
|
||||||
|
func TestMakeCTypeList(t *testing.T) {
|
||||||
|
tests := []struct {
|
||||||
|
name string
|
||||||
|
ctyp CKind
|
||||||
|
expected CType
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
name: "ValidTypeString",
|
||||||
|
ctyp: CKindString,
|
||||||
|
expected: CType(CKindString) | CTypeList,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "ValidTypeInt",
|
||||||
|
ctyp: CKindInt,
|
||||||
|
expected: CType(CKindInt) | CTypeList,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "InvalidType",
|
||||||
|
ctyp: CKindInvalid,
|
||||||
|
expected: CType(CKindInvalid),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "OutOfRangeType",
|
||||||
|
ctyp: maxCKind,
|
||||||
|
expected: CType(CKindInvalid),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "ArbitraryInvalidType",
|
||||||
|
ctyp: CKind(0xFFFF),
|
||||||
|
expected: CType(CKindInvalid),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "AggregateTypeAsInput",
|
||||||
|
ctyp: CKindCValue,
|
||||||
|
expected: CType(CKindCValue) | CTypeList,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, tt := range tests {
|
||||||
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
|
result := MakeCTypeList(tt.ctyp)
|
||||||
|
if result != tt.expected {
|
||||||
|
t.Errorf("MakeCTypeList(%v): expected %v (0x%04x), got %v (0x%04x)", tt.ctyp, tt.expected, tt.expected, result, result)
|
||||||
|
}
|
||||||
|
if result&0xC000 != 0 {
|
||||||
|
t.Errorf("MakeCTypeList(%v): bits 14-15 should be 0, got %v (0x%04x)", tt.ctyp, result, result)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// TestMakeCTypeMap verifica la función MakeCTypeMap
|
||||||
|
func TestMakeCTypeMap(t *testing.T) {
|
||||||
|
tests := []struct {
|
||||||
|
name string
|
||||||
|
ctyp CKind
|
||||||
|
ktyp CKind
|
||||||
|
expected CType
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
name: "ValidStringInt",
|
||||||
|
ctyp: CKindString,
|
||||||
|
ktyp: CKindInt,
|
||||||
|
expected: CType(CKindString) | CType(CKindInt<<keyTypeShift) | CTypeMap,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "InvalidValueType",
|
||||||
|
ctyp: CKindInvalid,
|
||||||
|
ktyp: CKindInt,
|
||||||
|
expected: CType(CKindInvalid),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "InvalidKeyType",
|
||||||
|
ctyp: CKindString,
|
||||||
|
ktyp: CKindInvalid,
|
||||||
|
expected: CType(CKindInvalid),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "OutOfRangeValueType",
|
||||||
|
ctyp: maxCKind,
|
||||||
|
ktyp: CKindInt,
|
||||||
|
expected: CType(CKindInvalid),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "OutOfRangeKeyType",
|
||||||
|
ctyp: CKindString,
|
||||||
|
ktyp: maxCKind,
|
||||||
|
expected: CType(CKindInvalid),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "ArbitraryInvalidValueType",
|
||||||
|
ctyp: CKind(0xFFFF),
|
||||||
|
ktyp: CKindInt,
|
||||||
|
expected: CType(CKindInvalid),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "ArbitraryInvalidKeyType",
|
||||||
|
ctyp: CKindString,
|
||||||
|
ktyp: CKind(0xFFFF),
|
||||||
|
expected: CType(CKindInvalid),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "AggregateTypeAsValue",
|
||||||
|
ctyp: CKindCValue,
|
||||||
|
ktyp: CKindInt,
|
||||||
|
expected: CType(CKindCValue) | CType(CKindInt<<keyTypeShift) | CTypeMap,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "AggregateTypeAsKey",
|
||||||
|
ctyp: CKindString,
|
||||||
|
ktyp: CKindCValue,
|
||||||
|
expected: CType(CKindString) | CType(CKindCValue<<keyTypeShift) | CTypeMap,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, tt := range tests {
|
||||||
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
|
result := MakeCTypeMap(tt.ctyp, tt.ktyp)
|
||||||
|
if result != tt.expected {
|
||||||
|
t.Errorf("MakeCTypeMap(%v, %v): expected %v (0x%04x), got %v (0x%04x)", tt.ctyp, tt.ktyp, tt.expected, tt.expected, result, result)
|
||||||
|
}
|
||||||
|
if result&0xC000 != 0 {
|
||||||
|
t.Errorf("MakeCTypeMap(%v, %v): bits 14-15 should be 0, got %v (0x%04x)", tt.ctyp, tt.ktyp, result, result)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// TestMakeCTypeDefer verifica la función MakeCTypeDefer
|
||||||
|
func TestMakeCTypeDefer(t *testing.T) {
|
||||||
|
tests := []struct {
|
||||||
|
name string
|
||||||
|
ctyp CKind
|
||||||
|
expected CType
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
name: "ValidTypeString",
|
||||||
|
ctyp: CKindString,
|
||||||
|
expected: CType(CKindString) | CTypeDefer,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "ValidTypeInt",
|
||||||
|
ctyp: CKindInt,
|
||||||
|
expected: CType(CKindInt) | CTypeDefer,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "InvalidType",
|
||||||
|
ctyp: CKindInvalid,
|
||||||
|
expected: CType(CKindInvalid),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "OutOfRangeType",
|
||||||
|
ctyp: maxCKind,
|
||||||
|
expected: CType(CKindInvalid),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "ArbitraryInvalidType",
|
||||||
|
ctyp: CKind(0xFFFF),
|
||||||
|
expected: CType(CKindInvalid),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "AggregateTypeAsInput",
|
||||||
|
ctyp: CKindCValue,
|
||||||
|
expected: CType(CKindCValue) | CTypeDefer,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, tt := range tests {
|
||||||
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
|
result := MakeCTypeDefer(tt.ctyp)
|
||||||
|
if result != tt.expected {
|
||||||
|
t.Errorf("MakeCTypeDefer(%v): expected %v (0x%04x), got %v (0x%04x)", tt.ctyp, tt.expected, tt.expected, result, result)
|
||||||
|
}
|
||||||
|
if result&0xC000 != 0 {
|
||||||
|
t.Errorf("MakeCTypeDefer(%v): bits 14-15 should be 0, got %v (0x%04x)", tt.ctyp, result, result)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// TestValueType verifica el método ValueType
|
||||||
|
func TestValueType(t *testing.T) {
|
||||||
|
tests := []struct {
|
||||||
|
name string
|
||||||
|
input CType
|
||||||
|
expected CKind
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
name: "SimpleString",
|
||||||
|
input: MakeCType(CKindString),
|
||||||
|
expected: CKindString,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "ListInt",
|
||||||
|
input: MakeCTypeList(CKindInt),
|
||||||
|
expected: CKindInt,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "MapStringInt",
|
||||||
|
input: MakeCTypeMap(CKindString, CKindInt),
|
||||||
|
expected: CKindString,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "DeferredInvalid",
|
||||||
|
input: MakeCTypeDefer(CKindInvalid),
|
||||||
|
expected: CKindInvalid,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "InvalidBits",
|
||||||
|
input: CType(0xFFFF),
|
||||||
|
expected: 0x003F,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, tt := range tests {
|
||||||
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
|
result := tt.input.ValueKind()
|
||||||
|
if result != tt.expected {
|
||||||
|
t.Errorf("ValueType(): expected %v (0x%04x), got %v (0x%04x)", tt.expected, tt.expected, result, result)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// TestKeyType verifica el método KeyType
|
||||||
|
func TestKeyType(t *testing.T) {
|
||||||
|
tests := []struct {
|
||||||
|
name string
|
||||||
|
input CType
|
||||||
|
expected CKind
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
name: "SimpleString",
|
||||||
|
input: MakeCType(CKindString),
|
||||||
|
expected: 0,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "MapStringInt",
|
||||||
|
input: MakeCTypeMap(CKindString, CKindInt),
|
||||||
|
expected: CKindInt,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "ListInt",
|
||||||
|
input: MakeCTypeList(CKindInt),
|
||||||
|
expected: 0,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "InvalidBits",
|
||||||
|
input: CType(0xFFFF),
|
||||||
|
expected: 0x3F,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, tt := range tests {
|
||||||
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
|
result := tt.input.KeyKind()
|
||||||
|
if result != tt.expected {
|
||||||
|
t.Errorf("KeyType(): expected %v (0x%04x), got %v (0x%04x)", tt.expected, tt.expected, result, result)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// TestDataType verifica el método DataType
|
||||||
|
func TestDataType(t *testing.T) {
|
||||||
|
tests := []struct {
|
||||||
|
name string
|
||||||
|
input CType
|
||||||
|
expected CType
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
name: "SimpleString",
|
||||||
|
input: MakeCType(CKindString),
|
||||||
|
expected: CTypeSimple,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "ListInt",
|
||||||
|
input: MakeCTypeList(CKindInt),
|
||||||
|
expected: CTypeList,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "MapStringInt",
|
||||||
|
input: MakeCTypeMap(CKindString, CKindInt),
|
||||||
|
expected: CTypeMap,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "DeferredString",
|
||||||
|
input: MakeCTypeDefer(CKindString),
|
||||||
|
expected: CTypeDefer,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "InvalidBits",
|
||||||
|
input: CType(0xFFFF),
|
||||||
|
expected: CTypeMap,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, tt := range tests {
|
||||||
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
|
result := tt.input.DataType()
|
||||||
|
if result != tt.expected {
|
||||||
|
t.Errorf("DataType(): expected %v (0x%04x), got %v (0x%04x)", tt.expected, tt.expected, result, result)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// TestIsSimple verifica el método IsSimple
|
||||||
|
func TestIsSimple(t *testing.T) {
|
||||||
|
tests := []struct {
|
||||||
|
name string
|
||||||
|
input CType
|
||||||
|
expected bool
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
name: "SimpleString",
|
||||||
|
input: MakeCType(CKindString),
|
||||||
|
expected: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "ListInt",
|
||||||
|
input: MakeCTypeList(CKindInt),
|
||||||
|
expected: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "MapStringInt",
|
||||||
|
input: MakeCTypeMap(CKindString, CKindInt),
|
||||||
|
expected: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "DeferredString",
|
||||||
|
input: MakeCTypeDefer(CKindString),
|
||||||
|
expected: false,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, tt := range tests {
|
||||||
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
|
result := tt.input.IsSimple()
|
||||||
|
if result != tt.expected {
|
||||||
|
t.Errorf("IsSimple(): expected %v, got %v", tt.expected, result)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// TestIsDefer verifica el método IsDefer
|
||||||
|
func TestIsDefer(t *testing.T) {
|
||||||
|
tests := []struct {
|
||||||
|
name string
|
||||||
|
input CType
|
||||||
|
expected bool
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
name: "DeferredString",
|
||||||
|
input: MakeCTypeDefer(CKindString),
|
||||||
|
expected: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "SimpleString",
|
||||||
|
input: MakeCType(CKindString),
|
||||||
|
expected: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "ListInt",
|
||||||
|
input: MakeCTypeList(CKindInt),
|
||||||
|
expected: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "MapStringInt",
|
||||||
|
input: MakeCTypeMap(CKindString, CKindInt),
|
||||||
|
expected: false,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, tt := range tests {
|
||||||
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
|
result := tt.input.IsDefer()
|
||||||
|
if result != tt.expected {
|
||||||
|
t.Errorf("IsDefer(): expected %v, got %v", tt.expected, result)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// TestIsMap verifica el método IsMap
|
||||||
|
func TestIsMap(t *testing.T) {
|
||||||
|
tests := []struct {
|
||||||
|
name string
|
||||||
|
input CType
|
||||||
|
expected bool
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
name: "MapStringInt",
|
||||||
|
input: MakeCTypeMap(CKindString, CKindInt),
|
||||||
|
expected: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "SimpleString",
|
||||||
|
input: MakeCType(CKindString),
|
||||||
|
expected: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "ListInt",
|
||||||
|
input: MakeCTypeList(CKindInt),
|
||||||
|
expected: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "DeferredString",
|
||||||
|
input: MakeCTypeDefer(CKindString),
|
||||||
|
expected: false,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, tt := range tests {
|
||||||
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
|
result := tt.input.IsMap()
|
||||||
|
if result != tt.expected {
|
||||||
|
t.Errorf("IsMap(): expected %v, got %v", tt.expected, result)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// TestIsList verifica el método IsList
|
||||||
|
func TestIsList(t *testing.T) {
|
||||||
|
tests := []struct {
|
||||||
|
name string
|
||||||
|
input CType
|
||||||
|
expected bool
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
name: "ListInt",
|
||||||
|
input: MakeCTypeList(CKindInt),
|
||||||
|
expected: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "SimpleString",
|
||||||
|
input: MakeCType(CKindString),
|
||||||
|
expected: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "MapStringInt",
|
||||||
|
input: MakeCTypeMap(CKindString, CKindInt),
|
||||||
|
expected: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "DeferredString",
|
||||||
|
input: MakeCTypeDefer(CKindString),
|
||||||
|
expected: false,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, tt := range tests {
|
||||||
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
|
result := tt.input.IsList()
|
||||||
|
if result != tt.expected {
|
||||||
|
t.Errorf("IsList(): expected %v, got %v", tt.expected, result)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// TestIsValid verifica el método IsValid
|
||||||
|
func TestIsValid(t *testing.T) {
|
||||||
|
tests := []struct {
|
||||||
|
name string
|
||||||
|
input CType
|
||||||
|
expected bool
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
name: "SimpleString",
|
||||||
|
input: MakeCType(CKindString),
|
||||||
|
expected: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "ListInt",
|
||||||
|
input: MakeCTypeList(CKindInt),
|
||||||
|
expected: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "MapStringInt",
|
||||||
|
input: MakeCTypeMap(CKindString, CKindInt),
|
||||||
|
expected: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "DeferredString",
|
||||||
|
input: MakeCTypeDefer(CKindString),
|
||||||
|
expected: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "InvalidValueType",
|
||||||
|
input: MakeCType(CKindInvalid),
|
||||||
|
expected: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "InvalidList",
|
||||||
|
input: MakeCTypeList(CKindInvalid),
|
||||||
|
expected: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "InvalidMapValueType",
|
||||||
|
input: MakeCTypeMap(CKindInvalid, CKindInt),
|
||||||
|
expected: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "InvalidMapKeyType",
|
||||||
|
input: MakeCTypeMap(CKindString, CKindInvalid),
|
||||||
|
expected: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "OutOfRangeValueType",
|
||||||
|
input: CType(maxCKind),
|
||||||
|
expected: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "OutOfRangeCompType",
|
||||||
|
input: CType(CKindString) | CType(4<<compoundTypeShift),
|
||||||
|
expected: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "OutOfRangeKeyType",
|
||||||
|
input: MakeCTypeMap(CKindString, maxCKind),
|
||||||
|
expected: false,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, tt := range tests {
|
||||||
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
|
result := tt.input.IsValid()
|
||||||
|
if result != tt.expected {
|
||||||
|
t.Errorf("IsValid(): expected %v, got %v for input %v (0x%04x)", tt.expected, result, tt.input, tt.input)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// TestSanitize verifica el método Sanitize
|
||||||
|
func TestSanitize(t *testing.T) {
|
||||||
|
tests := []struct {
|
||||||
|
name string
|
||||||
|
input CType
|
||||||
|
expected CType
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
name: "ValidSimpleString",
|
||||||
|
input: MakeCType(CKindString),
|
||||||
|
expected: MakeCType(CKindString),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "ValidMapStringInt",
|
||||||
|
input: MakeCTypeMap(CKindString, CKindInt),
|
||||||
|
expected: MakeCTypeMap(CKindString, CKindInt),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "InvalidValueType",
|
||||||
|
input: MakeCType(CKindInvalid),
|
||||||
|
expected: CType(CKindInvalid),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "InvalidMapKeyType",
|
||||||
|
input: MakeCTypeMap(CKindString, CKindInvalid),
|
||||||
|
expected: CType(CKindInvalid),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "OutOfRangeCompType",
|
||||||
|
input: CType(CKindString) | CType(4<<compoundTypeShift),
|
||||||
|
expected: CType(CKindInvalid),
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, tt := range tests {
|
||||||
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
|
result := tt.input.Sanitize()
|
||||||
|
if result != tt.expected {
|
||||||
|
t.Errorf("Sanitize(): expected %v (0x%04x), got %v (0x%04x) for input %v (0x%04x)",
|
||||||
|
tt.expected, tt.expected, result, result, tt.input, tt.input)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// TestCKindString verifica el método String para CKind
|
||||||
|
func TestCKindString(t *testing.T) {
|
||||||
|
tests := []struct {
|
||||||
|
name string
|
||||||
|
input CKind
|
||||||
|
expected string
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
name: "TypeInvalid",
|
||||||
|
input: CKindInvalid,
|
||||||
|
expected: "invalid",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "TypeInt",
|
||||||
|
input: CKindInt,
|
||||||
|
expected: "int",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "TypeString",
|
||||||
|
input: CKindString,
|
||||||
|
expected: "string",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Invalid",
|
||||||
|
input: maxCKind,
|
||||||
|
expected: "invalid",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, tt := range tests {
|
||||||
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
|
result := tt.input.String()
|
||||||
|
if result != tt.expected {
|
||||||
|
t.Errorf("String(): expected %q, got %q for input %v (0x%04x)", tt.expected, result, tt.input, tt.input)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// TestCTypeString verifica el método String para CType
|
||||||
|
func TestCTypeString(t *testing.T) {
|
||||||
|
// Log para verificar ctypeCompoundNames
|
||||||
|
t.Logf("ctypeCompoundNames: %v (length: %d)", ctypeNames, len(ctypeNames))
|
||||||
|
|
||||||
|
tests := []struct {
|
||||||
|
name string
|
||||||
|
input CType
|
||||||
|
expected string
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
name: "SimpleString",
|
||||||
|
input: MakeCType(CKindString),
|
||||||
|
expected: "string",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "DeferInt",
|
||||||
|
input: MakeCTypeDefer(CKindInt),
|
||||||
|
expected: "defer|int",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "ListBool",
|
||||||
|
input: MakeCTypeList(CKindBool),
|
||||||
|
expected: "list|bool",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "MapStringInt",
|
||||||
|
input: MakeCTypeMap(CKindString, CKindInt),
|
||||||
|
expected: "map|int&string",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "InvalidValueType",
|
||||||
|
input: MakeCType(CKindInvalid),
|
||||||
|
expected: "invalid",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "InvalidMapKeyType",
|
||||||
|
input: MakeCTypeMap(CKindString, CKindInvalid),
|
||||||
|
expected: "invalid",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "OutOfRangeCompType",
|
||||||
|
input: CType(CKindString) | CType(4<<compoundTypeShift),
|
||||||
|
expected: "invalid",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "InvalidBits",
|
||||||
|
input: CType(0xFFFF),
|
||||||
|
expected: "invalid",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "DebugMapStringInt",
|
||||||
|
input: MakeCTypeMap(CKindString, CKindInt),
|
||||||
|
expected: "map|int&string",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, tt := range tests {
|
||||||
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
|
result := tt.input.String()
|
||||||
|
if result != tt.expected {
|
||||||
|
t.Errorf("String(): expected %q, got %q for input %v (0x%04x), compTypeMask=0x%04x, compoundIndex=%d",
|
||||||
|
tt.expected, result, tt.input, tt.input, tt.input&compTypeMask, (tt.input&compTypeMask)>>compoundTypeShift)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,552 +0,0 @@
|
|||||||
package cval
|
|
||||||
|
|
||||||
import (
|
|
||||||
"testing"
|
|
||||||
)
|
|
||||||
|
|
||||||
// TestMakeCValue verifica la función MakeCValue
|
|
||||||
func TestMakeCValue(t *testing.T) {
|
|
||||||
tests := []struct {
|
|
||||||
name string
|
|
||||||
ctyp CType
|
|
||||||
expected CValueSpec
|
|
||||||
}{
|
|
||||||
{
|
|
||||||
name: "ValidTypeString",
|
|
||||||
ctyp: TypeString,
|
|
||||||
expected: CValueSpec(TypeString),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "ValidTypeInt",
|
|
||||||
ctyp: TypeInt,
|
|
||||||
expected: CValueSpec(TypeInt),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "InvalidType",
|
|
||||||
ctyp: TypeInvalid,
|
|
||||||
expected: CValueSpec(TypeInvalid),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "OutOfRangeType",
|
|
||||||
ctyp: TypeError + 1,
|
|
||||||
expected: CValueSpec(TypeError+1) & valueTypeMask,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "AggregateTypeAsInput",
|
|
||||||
ctyp: TypeDefer,
|
|
||||||
expected: CValueSpec(0),
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, tt := range tests {
|
|
||||||
t.Run(tt.name, func(t *testing.T) {
|
|
||||||
result := MakeCValue(tt.ctyp)
|
|
||||||
if result != tt.expected {
|
|
||||||
t.Errorf("MakeCValue(%v): expected %v (0x%04x), got %v (0x%04x)", tt.ctyp, tt.expected, tt.expected, result, result)
|
|
||||||
}
|
|
||||||
if result&0xC000 != 0 {
|
|
||||||
t.Errorf("MakeCValue(%v): bits 14-15 should be 0, got %v (0x%04x)", tt.ctyp, result, result)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// TestMakeCList verifica la función MakeCList
|
|
||||||
func TestMakeCList(t *testing.T) {
|
|
||||||
tests := []struct {
|
|
||||||
name string
|
|
||||||
ctyp CType
|
|
||||||
expected CValueSpec
|
|
||||||
}{
|
|
||||||
{
|
|
||||||
name: "ValidTypeString",
|
|
||||||
ctyp: TypeString,
|
|
||||||
expected: CValueSpec(TypeString) | compoundList,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "ValidTypeInt",
|
|
||||||
ctyp: TypeInt,
|
|
||||||
expected: CValueSpec(TypeInt) | compoundList,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "InvalidType",
|
|
||||||
ctyp: TypeInvalid,
|
|
||||||
expected: CValueSpec(TypeInvalid) | compoundList,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "AggregateTypeAsInput",
|
|
||||||
ctyp: TypeList,
|
|
||||||
expected: CValueSpec(0) | compoundList,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, tt := range tests {
|
|
||||||
t.Run(tt.name, func(t *testing.T) {
|
|
||||||
result := MakeCList(tt.ctyp)
|
|
||||||
if result != tt.expected {
|
|
||||||
t.Errorf("MakeCList(%v): expected %v (0x%04x), got %v (0x%04x)", tt.ctyp, tt.expected, tt.expected, result, result)
|
|
||||||
}
|
|
||||||
if result&0xC000 != 0 {
|
|
||||||
t.Errorf("MakeCList(%v): bits 14-15 should be 0, got %v (0x%04x)", tt.ctyp, result, result)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// TestMakeCMap verifica la función MakeCMap
|
|
||||||
func TestMakeCMap(t *testing.T) {
|
|
||||||
tests := []struct {
|
|
||||||
name string
|
|
||||||
ctyp CType
|
|
||||||
ktyp CType
|
|
||||||
expected CValueSpec
|
|
||||||
}{
|
|
||||||
{
|
|
||||||
name: "ValidStringInt",
|
|
||||||
ctyp: TypeString,
|
|
||||||
ktyp: TypeInt,
|
|
||||||
expected: CValueSpec(TypeString) | CValueSpec(TypeInt<<keyTypeShift) | compoundMap,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "InvalidValueType",
|
|
||||||
ctyp: TypeInvalid,
|
|
||||||
ktyp: TypeInt,
|
|
||||||
expected: CValueSpec(TypeInvalid) | CValueSpec(TypeInt<<keyTypeShift) | compoundMap,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "InvalidKeyType",
|
|
||||||
ctyp: TypeString,
|
|
||||||
ktyp: TypeInvalid,
|
|
||||||
expected: CValueSpec(TypeString) | CValueSpec(TypeInvalid<<keyTypeShift) | compoundMap,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "AggregateTypeAsValue",
|
|
||||||
ctyp: TypeMap,
|
|
||||||
ktyp: TypeInt,
|
|
||||||
expected: CValueSpec(0) | CValueSpec(TypeInt<<keyTypeShift) | compoundMap,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "AggregateTypeAsKey",
|
|
||||||
ctyp: TypeString,
|
|
||||||
ktyp: TypeMap,
|
|
||||||
expected: CValueSpec(TypeString) | CValueSpec(0<<keyTypeShift) | compoundMap,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, tt := range tests {
|
|
||||||
t.Run(tt.name, func(t *testing.T) {
|
|
||||||
result := MakeCMap(tt.ctyp, tt.ktyp)
|
|
||||||
if result != tt.expected {
|
|
||||||
t.Errorf("MakeCMap(%v, %v): expected %v (0x%04x), got %v (0x%04x)", tt.ctyp, tt.ktyp, tt.expected, tt.expected, result, result)
|
|
||||||
}
|
|
||||||
if result&0xC000 != 0 {
|
|
||||||
t.Errorf("MakeCMap(%v, %v): bits 14-15 should be 0, got %v (0x%04x)", tt.ctyp, tt.ktyp, result, result)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// TestMakeCDeferred verifica la función MakeCDeferred
|
|
||||||
func TestMakeCDeferred(t *testing.T) {
|
|
||||||
tests := []struct {
|
|
||||||
name string
|
|
||||||
ctyp CType
|
|
||||||
expected CValueSpec
|
|
||||||
}{
|
|
||||||
{
|
|
||||||
name: "ValidTypeString",
|
|
||||||
ctyp: TypeString,
|
|
||||||
expected: CValueSpec(TypeString) | compoundDefer,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "ValidTypeInt",
|
|
||||||
ctyp: TypeInt,
|
|
||||||
expected: CValueSpec(TypeInt) | compoundDefer,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "InvalidType",
|
|
||||||
ctyp: TypeInvalid,
|
|
||||||
expected: CValueSpec(TypeInvalid) | compoundDefer,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "AggregateTypeAsInput",
|
|
||||||
ctyp: TypeDefer,
|
|
||||||
expected: CValueSpec(0) | compoundDefer,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, tt := range tests {
|
|
||||||
t.Run(tt.name, func(t *testing.T) {
|
|
||||||
result := MakeCDeferred(tt.ctyp)
|
|
||||||
if result != tt.expected {
|
|
||||||
t.Errorf("MakeCDeferred(%v): expected %v (0x%04x), got %v (0x%04x)", tt.ctyp, tt.expected, tt.expected, result, result)
|
|
||||||
}
|
|
||||||
if result&0xC000 != 0 {
|
|
||||||
t.Errorf("MakeCDeferred(%v): bits 14-15 should be 0, got %v (0x%04x)", tt.ctyp, result, result)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// TestValueType verifica el método ValueType
|
|
||||||
func TestValueType(t *testing.T) {
|
|
||||||
tests := []struct {
|
|
||||||
name string
|
|
||||||
input CValueSpec
|
|
||||||
expected CType
|
|
||||||
}{
|
|
||||||
{
|
|
||||||
name: "SimpleString",
|
|
||||||
input: MakeCValue(TypeString),
|
|
||||||
expected: TypeString,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "ListInt",
|
|
||||||
input: MakeCList(TypeInt),
|
|
||||||
expected: TypeInt,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "MapStringInt",
|
|
||||||
input: MakeCMap(TypeString, TypeInt),
|
|
||||||
expected: TypeString,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "DeferredInvalid",
|
|
||||||
input: MakeCDeferred(TypeInvalid),
|
|
||||||
expected: TypeInvalid,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "InvalidBits",
|
|
||||||
input: CValueSpec(0xFFFF),
|
|
||||||
expected: 0x003F, // Máscara 0x003F limita a 6 bits (63)
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, tt := range tests {
|
|
||||||
t.Run(tt.name, func(t *testing.T) {
|
|
||||||
result := tt.input.ValueType()
|
|
||||||
if result != tt.expected {
|
|
||||||
t.Errorf("ValueType(): expected %v (0x%04x), got %v (0x%04x)", tt.expected, tt.expected, result, result)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// TestKeyType verifica el método KeyType
|
|
||||||
func TestKeyType(t *testing.T) {
|
|
||||||
tests := []struct {
|
|
||||||
name string
|
|
||||||
input CValueSpec
|
|
||||||
expected CType
|
|
||||||
}{
|
|
||||||
{
|
|
||||||
name: "SimpleString",
|
|
||||||
input: MakeCValue(TypeString),
|
|
||||||
expected: 0,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "MapStringInt",
|
|
||||||
input: MakeCMap(TypeString, TypeInt),
|
|
||||||
expected: TypeInt,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "ListInt",
|
|
||||||
input: MakeCList(TypeInt),
|
|
||||||
expected: 0,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "InvalidBits",
|
|
||||||
input: CValueSpec(0xFFFF),
|
|
||||||
expected: 0x3F,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, tt := range tests {
|
|
||||||
t.Run(tt.name, func(t *testing.T) {
|
|
||||||
result := tt.input.KeyType()
|
|
||||||
if result != tt.expected {
|
|
||||||
t.Errorf("KeyType(): expected %v (0x%04x), got %v (0x%04x)", tt.expected, tt.expected, result, result)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// TestCompoundType verifica el método CompoundType
|
|
||||||
func TestCompoundType(t *testing.T) {
|
|
||||||
tests := []struct {
|
|
||||||
name string
|
|
||||||
input CValueSpec
|
|
||||||
expected CType
|
|
||||||
}{
|
|
||||||
{
|
|
||||||
name: "SimpleString",
|
|
||||||
input: MakeCValue(TypeString),
|
|
||||||
expected: TypeSimple,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "ListInt",
|
|
||||||
input: MakeCList(TypeInt),
|
|
||||||
expected: TypeList,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "MapStringInt",
|
|
||||||
input: MakeCMap(TypeString, TypeInt),
|
|
||||||
expected: TypeMap,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "DeferredString",
|
|
||||||
input: MakeCDeferred(TypeString),
|
|
||||||
expected: TypeDefer,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "InvalidBits",
|
|
||||||
input: CValueSpec(0xFFFF),
|
|
||||||
expected: TypeMap, // Máscara 0x00C0 limita a bits 6-7 (0x00C0 = TypeMap)
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, tt := range tests {
|
|
||||||
t.Run(tt.name, func(t *testing.T) {
|
|
||||||
result := tt.input.CompoundType()
|
|
||||||
if result != tt.expected {
|
|
||||||
t.Errorf("CompoundType(): expected %v (0x%04x), got %v (0x%04x)", tt.expected, tt.expected, result, result)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// TestIsDefer verifica el método IsDefer
|
|
||||||
func TestIsDefer(t *testing.T) {
|
|
||||||
tests := []struct {
|
|
||||||
name string
|
|
||||||
input CValueSpec
|
|
||||||
expected bool
|
|
||||||
}{
|
|
||||||
{
|
|
||||||
name: "DeferredString",
|
|
||||||
input: MakeCDeferred(TypeString),
|
|
||||||
expected: true,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "SimpleString",
|
|
||||||
input: MakeCValue(TypeString),
|
|
||||||
expected: false,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "ListInt",
|
|
||||||
input: MakeCList(TypeInt),
|
|
||||||
expected: false,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "MapStringInt",
|
|
||||||
input: MakeCMap(TypeString, TypeInt),
|
|
||||||
expected: false,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, tt := range tests {
|
|
||||||
t.Run(tt.name, func(t *testing.T) {
|
|
||||||
result := tt.input.IsDefer()
|
|
||||||
if result != tt.expected {
|
|
||||||
t.Errorf("IsDefer(): expected %v, got %v", tt.expected, result)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// TestIsMap verifica el método IsMap
|
|
||||||
func TestIsMap(t *testing.T) {
|
|
||||||
tests := []struct {
|
|
||||||
name string
|
|
||||||
input CValueSpec
|
|
||||||
expected bool
|
|
||||||
}{
|
|
||||||
{
|
|
||||||
name: "MapStringInt",
|
|
||||||
input: MakeCMap(TypeString, TypeInt),
|
|
||||||
expected: true,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "SimpleString",
|
|
||||||
input: MakeCValue(TypeString),
|
|
||||||
expected: false,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "ListInt",
|
|
||||||
input: MakeCList(TypeInt),
|
|
||||||
expected: false,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "DeferredString",
|
|
||||||
input: MakeCDeferred(TypeString),
|
|
||||||
expected: false,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, tt := range tests {
|
|
||||||
t.Run(tt.name, func(t *testing.T) {
|
|
||||||
result := tt.input.IsMap()
|
|
||||||
if result != tt.expected {
|
|
||||||
t.Errorf("IsMap(): expected %v, got %v", tt.expected, result)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// TestIsList verifica el método IsList
|
|
||||||
func TestIsList(t *testing.T) {
|
|
||||||
tests := []struct {
|
|
||||||
name string
|
|
||||||
input CValueSpec
|
|
||||||
expected bool
|
|
||||||
}{
|
|
||||||
{
|
|
||||||
name: "ListInt",
|
|
||||||
input: MakeCList(TypeInt),
|
|
||||||
expected: true,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "SimpleString",
|
|
||||||
input: MakeCValue(TypeString),
|
|
||||||
expected: false,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "MapStringInt",
|
|
||||||
input: MakeCMap(TypeString, TypeInt),
|
|
||||||
expected: false,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "DeferredString",
|
|
||||||
input: MakeCDeferred(TypeString),
|
|
||||||
expected: false,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, tt := range tests {
|
|
||||||
t.Run(tt.name, func(t *testing.T) {
|
|
||||||
result := tt.input.IsList()
|
|
||||||
if result != tt.expected {
|
|
||||||
t.Errorf("IsList(): expected %v, got %v", tt.expected, result)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// TestIsValid verifica el método IsValid
|
|
||||||
func TestIsValid(t *testing.T) {
|
|
||||||
tests := []struct {
|
|
||||||
name string
|
|
||||||
input CValueSpec
|
|
||||||
expected bool
|
|
||||||
}{
|
|
||||||
{
|
|
||||||
name: "SimpleString",
|
|
||||||
input: MakeCValue(TypeString),
|
|
||||||
expected: true,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "ListInt",
|
|
||||||
input: MakeCList(TypeInt),
|
|
||||||
expected: true,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "MapStringInt",
|
|
||||||
input: MakeCMap(TypeString, TypeInt),
|
|
||||||
expected: true,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "DeferredString",
|
|
||||||
input: MakeCDeferred(TypeString),
|
|
||||||
expected: true,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "InvalidValueType",
|
|
||||||
input: MakeCValue(TypeInvalid),
|
|
||||||
expected: false,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "InvalidList",
|
|
||||||
input: MakeCList(TypeInvalid),
|
|
||||||
expected: false,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "InvalidMapValueType",
|
|
||||||
input: MakeCMap(TypeInvalid, TypeInt),
|
|
||||||
expected: false,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "InvalidMapKeyType",
|
|
||||||
input: MakeCMap(TypeString, TypeInvalid),
|
|
||||||
expected: false,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "OutOfRangeValueType",
|
|
||||||
input: CValueSpec(maxValueType << valueTypeShift) | compoundNone,
|
|
||||||
expected: false,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "OutOfRangeAggType",
|
|
||||||
input: CValueSpec(TypeString) | CValueSpec(4<<compoundTypeShift),
|
|
||||||
expected: false,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "OutOfRangeKeyType",
|
|
||||||
input: MakeCMap(TypeString, maxValueType),
|
|
||||||
expected: false,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, tt := range tests {
|
|
||||||
t.Run(tt.name, func(t *testing.T) {
|
|
||||||
result := tt.input.IsValid()
|
|
||||||
if result != tt.expected {
|
|
||||||
t.Errorf("IsValid(): expected %v, got %v for input %v (0x%04x)", tt.expected, result, tt.input, tt.input)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// TestSanitize verifica el método Sanitize
|
|
||||||
func TestSanitize(t *testing.T) {
|
|
||||||
tests := []struct {
|
|
||||||
name string
|
|
||||||
input CValueSpec
|
|
||||||
expected CValueSpec
|
|
||||||
}{
|
|
||||||
{
|
|
||||||
name: "ValidSimpleString",
|
|
||||||
input: MakeCValue(TypeString),
|
|
||||||
expected: MakeCValue(TypeString),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "ValidMapStringInt",
|
|
||||||
input: MakeCMap(TypeString, TypeInt),
|
|
||||||
expected: MakeCMap(TypeString, TypeInt),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "InvalidValueType",
|
|
||||||
input: MakeCValue(TypeInvalid),
|
|
||||||
expected: CValueSpec(TypeInvalid),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "InvalidMapKeyType",
|
|
||||||
input: MakeCMap(TypeString, TypeInvalid),
|
|
||||||
expected: CValueSpec(TypeInvalid),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "OutOfRangeAggType",
|
|
||||||
input: CValueSpec(TypeString) | CValueSpec(4<<compoundTypeShift),
|
|
||||||
expected: CValueSpec(TypeInvalid),
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, tt := range tests {
|
|
||||||
t.Run(tt.name, func(t *testing.T) {
|
|
||||||
result := tt.input.Sanitize()
|
|
||||||
if result != tt.expected {
|
|
||||||
t.Errorf("Sanitize(): expected %v (0x%04x), got %v (0x%04x) for input %v (0x%04x)",
|
|
||||||
tt.expected, tt.expected, result, result, tt.input, tt.input)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Loading…
Reference in new issue