master > master: codego - utils + unit tests, A1[0-9]+ mit testen

This commit is contained in:
RD
2021-05-18 11:32:32 +02:00
parent 2ab9b63a08
commit f292d7e5dc
4 changed files with 38 additions and 17 deletions

View File

@@ -205,8 +205,7 @@ func TestAtomsCalc1(test *testing.T) {
var val []string
fml = schema.ParseExpr("A0")
val = recursion.Atoms(fml)
utils.SortStrings(&val)
assert.Equal([]string{"A0"}, val)
assert.ElementsMatch([]string{"A0"}, val)
}
func TestAtomsCalc2(test *testing.T) {
@@ -216,8 +215,7 @@ func TestAtomsCalc2(test *testing.T) {
var val []string
fml = schema.ParseExpr("((( ! A8 && A3 ) || A4 ) && A0 )")
val = recursion.Atoms(fml)
utils.SortStrings(&val)
assert.Equal([]string{"A0", "A3", "A4", "A8"}, val)
assert.ElementsMatch([]string{"A0", "A3", "A4", "A8"}, val)
}
/* ---------------------------------------------------------------- *

View File

@@ -25,8 +25,13 @@ func TestParseExpr(test *testing.T) {
assert.Equal("atom", tree.GetKind())
assert.Equal(0, len(tree.GetSubFormulae()))
tree = schema.ParseExpr("A12")
assert.Equal("A12", tree.GetExpr())
assert.Equal("atom", tree.GetKind())
assert.Equal(0, len(tree.GetSubFormulae()))
tree = schema.ParseExpr(" ! A5 ")
assert.Equal("! A5", tree.GetExpr())
assert.Equal("!A5", tree.GetExpr())
assert.Equal("not", tree.GetKind())
assert.Equal(1, len(tree.GetSubFormulae()))
@@ -35,8 +40,8 @@ func TestParseExpr(test *testing.T) {
assert.Equal("implies", tree.GetKind())
assert.Equal(2, len(tree.GetSubFormulae()))
tree = schema.ParseExpr("( A0 && A1) || A2")
assert.Equal("((A0 && A1) || A2)", tree.GetExpr())
tree = schema.ParseExpr("( A0 && ! ! A1) || A2")
assert.Equal("((A0 && !!A1) || A2)", tree.GetExpr())
assert.Equal("or2", tree.GetKind())
assert.Equal(2, len(tree.GetSubFormulae()))
}