Skip to content

Commit

Permalink
fix: switch [][]byte split support to []byte
Browse files Browse the repository at this point in the history
  • Loading branch information
znd4 committed Nov 18, 2024
1 parent 6dee545 commit 1dd5a24
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 12 deletions.
2 changes: 1 addition & 1 deletion pkg/ottl/expression.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ func (g exprGetter[K]) Get(ctx context.Context, tCtx K) (any, error) {
if err != nil {
return nil, err
}
case [][]byte:
case []byte:
result, err = getElementByIndex(r, k.Int)
if err != nil {
return nil, err
Expand Down
18 changes: 7 additions & 11 deletions pkg/ottl/expression_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,11 @@ func basicSliceFloat() (ExprFunc[any], error) {
}, nil
}

func basicSliceBytes() (ExprFunc[any], error) {
func basicSliceByte() (ExprFunc[any], error) {
return func(_ context.Context, _ any) (any, error) {
return []any{
[][]byte{
[]byte("pass"),
[]byte{
byte('p'),
},
}, nil
}, nil
Expand Down Expand Up @@ -314,7 +314,6 @@ func Test_newGetter(t *testing.T) {
Function: "SliceBool",
Keys: []key{
{
// note for review: not sure if this is correct
Int: ottltest.Intp(0),
},
{
Expand All @@ -334,7 +333,6 @@ func Test_newGetter(t *testing.T) {
Function: "SliceInteger",
Keys: []key{
{
// note for review: not sure if this is correct
Int: ottltest.Intp(0),
},
{
Expand All @@ -354,7 +352,6 @@ func Test_newGetter(t *testing.T) {
Function: "SliceFloat",
Keys: []key{
{
// note for review: not sure if this is correct
Int: ottltest.Intp(0),
},
{
Expand All @@ -367,14 +364,13 @@ func Test_newGetter(t *testing.T) {
want: 1.0,
},
{
name: "function call nested SliceBytes",
name: "function call nested SliceByte",
val: value{
Literal: &mathExprLiteral{
Converter: &converter{
Function: "SliceBytes",
Function: "SliceByte",
Keys: []key{
{
// note for review: not sure if this is correct
Int: ottltest.Intp(0),
},
{
Expand All @@ -384,7 +380,7 @@ func Test_newGetter(t *testing.T) {
},
},
},
want: []byte("pass"),
want: byte('p'),
},
{
name: "enum",
Expand Down Expand Up @@ -685,7 +681,7 @@ func Test_newGetter(t *testing.T) {
createFactory("SliceBool", &struct{}{}, basicSliceBool),
createFactory("SliceInteger", &struct{}{}, basicSliceInteger),
createFactory("SliceFloat", &struct{}{}, basicSliceFloat),
createFactory("SliceBytes", &struct{}{}, basicSliceBytes),
createFactory("SliceByte", &struct{}{}, basicSliceByte),
)

p, _ := NewParser[any](
Expand Down

0 comments on commit 1dd5a24

Please sign in to comment.