Skip to content

Commit

Permalink
Create util_test.go
Browse files Browse the repository at this point in the history
  • Loading branch information
donnie4w committed Sep 5, 2024
1 parent 581d040 commit 3d167ec
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions util/util_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// Copyright (c) 2024, donnie <[email protected]>
// All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
//
// github.com/donnie4w/gdao

package util

import (
"fmt"
"testing"
)

func Test_evaluate(t *testing.T) {
context := map[string]interface{}{
"x": 10,
"y": "hello",
"z": nil,
"s": "11",
}

expressions := []string{
"nil==s",
"( x|1 < 3|15) && (y== 'hello') && (z == nil)",
"( x|1 < 3|15) && (y== \"hello\") && (z != nil)",
"( x|1 < 3|15) || (y== \"hello1\") && (z == nil)",
"( s==\"s\") && (y== \"hello\") && (z == nil)",
"'www>>>>2'!= null",
}

for _, expression := range expressions {
result, err := EvaluateWithContext(expression, context)
fmt.Println("Result:", result, ",Error:", err)
}
}

0 comments on commit 3d167ec

Please sign in to comment.