Skip to content

Commit

Permalink
Added test for nested cost calculation.
Browse files Browse the repository at this point in the history
  • Loading branch information
Antoine Popineau committed Jan 27, 2025
1 parent 133da12 commit 043934e
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions models/ast/ast_node_weight_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package ast

import (
"testing"

"github.com/stretchr/testify/assert"
)

func TestNodeWeights(t *testing.T) {
tts := []struct {
n Node
c int
}{
{Node{Function: FUNC_AND, Children: []Node{{Function: FUNC_DB_ACCESS}, {Function: FUNC_PAYLOAD}}}, 60},
{Node{Function: FUNC_AND, Children: []Node{{Function: FUNC_DB_ACCESS}, {
Function: FUNC_ADD, Children: []Node{{
Function: FUNC_AGGREGATOR,
Children: []Node{{Function: FUNC_CUSTOM_LIST_ACCESS}, {Function: FUNC_PAYLOAD}},
}},
}}}, 140},
}

for _, tt := range tts {
assert.Equal(t, tt.c, tt.n.Cost())
}
}

0 comments on commit 043934e

Please sign in to comment.