Skip to content

Commit

Permalink
fix patterns tests
Browse files Browse the repository at this point in the history
  • Loading branch information
rcoreilly committed Jan 6, 2025
1 parent 9431933 commit c6a5aa4
Showing 1 changed file with 142 additions and 141 deletions.
283 changes: 142 additions & 141 deletions patterns/patterns_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,48 +64,49 @@ func TestABAC(t *testing.T) {

exa := `A [6 3 3]
[r r c] [0] [1] [2]
[0 0] 0 1 0
[0 1] 1 0 1
[0 2] 0 0 0
[1 0] 1 0 1
[1 1] 1 0 0
[1 2] 0 0 0
[2 0] 0 0 0
[2 1] 1 0 0
[2 2] 1 1 0
[3 0] 0 1 0
[3 1] 0 0 0
[3 2] 1 0 1
[4 0] 1 0 1
[4 1] 0 1 0
[4 2] 0 0 0
[5 0] 1 0 0
[5 1] 0 0 1
[5 2] 1 0 0
[0 0] 0 1 1
[0 1] 0 0 0
[0 2] 0 0 1
[1 0] 1 0 0
[1 1] 0 0 0
[1 2] 0 1 1
[2 0] 1 1 0
[2 1] 0 0 0
[2 2] 0 0 1
[3 0] 0 0 0
[3 1] 0 1 0
[3 2] 1 1 0
[4 0] 0 1 0
[4 1] 0 0 0
[4 2] 1 1 0
[5 0] 0 0 1
[5 1] 0 1 1
[5 2] 0 0 0
`

// fmt.Println(a)
assert.Equal(t, exa, a.String())

exb := `B [6 3 3]
[r r c] [0] [1] [2]
[0 0] 1 0 0
[0 1] 0 1 0
[0 2] 1 0 0
[1 0] 1 0 0
[1 1] 1 1 0
[1 2] 0 0 0
[0 0] 0 1 0
[0 1] 0 0 0
[0 2] 1 1 0
[1 0] 0 0 0
[1 1] 0 1 1
[1 2] 1 0 0
[2 0] 0 0 0
[2 1] 0 1 1
[2 2] 0 0 1
[3 0] 1 1 0
[3 1] 0 0 0
[3 2] 0 1 0
[4 0] 0 0 0
[4 1] 1 1 0
[4 2] 1 0 0
[5 0] 0 0 0
[5 1] 0 0 1
[5 2] 1 1 0
[2 1] 1 0 1
[2 2] 0 1 0
[3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