func Test_QWord_Each(t *testing.T) { qb := query.QWordBuilder(strings.NewReader(` $user : ^(@)(.*)$ ${2} = String $test :: S $(2) = StringEnum `)) qword := qb.Parse("@zozoh , S(abc,hha, erer, jdgg gdg)") qword.Each(func(index int, qc *query.QCnd, prevIsAnd bool) { z.DebugPrintf("no.%d prevIsAnd.%v \n", index, prevIsAnd) z.DebugPrintln(qc.String()) }) }
func Test_QWord_Region(t *testing.T) { qb := query.QWordBuilder(strings.NewReader(` $ct :: C ${2} = IntRegion $st :: S ${2} = IntRegion $usr : ^(@)([a-zA-Z]+)$ ${2} = String `)) qword := qb.Parse("C[10,15], S(12,) , @pw") qword.Each(func(index int, qc *query.QCnd, prevIsAnd bool) { z.DebugPrintf("no.%d prevIsAnd.%v \n", index, prevIsAnd) z.DebugPrintln(qc.String()) }) qc := qword.Get("usr") if qc == nil { t.Error("can't find qcnd by key") } }