Ver código fonte

feat: 点位值逻辑运算 debug

gaoyagang 1 ano atrás
pai
commit
b23fe4c689
2 arquivos alterados com 4 adições e 4 exclusões
  1. 1 1
      identify/single.go
  2. 3 3
      identify/single_test.go

+ 1 - 1
identify/single.go

@@ -186,7 +186,7 @@ func (s *SingleItem) transVar(v ItemValue) ItemValue {
 func (s *SingleItem) compare(r string, v string) bool {
 	if strings.Index(r, "...") > -1 {
 		return s.compareRange(r, v)
-	} else if strings.Index(r, " ") > 1 {
+	} else if strings.Index(r, " ") >= 1 {
 		return s.compareLogic(r, v)
 	}
 

+ 3 - 3
identify/single_test.go

@@ -11,8 +11,8 @@ func TestStepTest(t *testing.T) {
 }
 
 func TestStepTest1(t *testing.T) {
-	// 值逻辑比较 > 0.3的情况
-	rule := `{"xxx":{"NvIn":["> 0.3"]}}`
-	x := StepTest("0", "0.31", rule)
+	// 值逻辑比较 > 0.00032的情况
+	rule := `{"xxx":{"NvIn":["> 0.00032"]}}`
+	x := StepTest("0", "0.00033", rule)
 	t.Log(x)
 }