| 1 | package build |
| 2 | |
| 3 | import "testing" |
| 4 | |
| 5 | func TestTree(t *testing.T) { |
| 6 | exp := "0 []" |
| 7 | if mess, diff := diff(Tree(1, 0).String(), exp); diff { |
| 8 | t.Errorf("Tree %s", mess) |
| 9 | } |
| 10 | |
| 11 | exp = "1 []" |
| 12 | if mess, diff := diff(Tree(1, 1).String(), exp); diff { |
| 13 | t.Errorf("Tree %s", mess) |
| 14 | } |
| 15 | |
| 16 | exp = "2 [{0 1}]" |
| 17 | if mess, diff := diff(Tree(1, 2).String(), exp); diff { |
| 18 | t.Errorf("Tree %s", mess) |
| 19 | } |
| 20 | |
| 21 | exp = "0 []" |
| 22 | if mess, diff := diff(Tree(2, 0).String(), exp); diff { |
| 23 | t.Errorf("Tree %s", mess) |
| 24 | } |
| 25 | |
| 26 | exp = "1 []" |
| 27 | if mess, diff := diff(Tree(2, 1).String(), exp); diff { |
| 28 | t.Errorf("Tree %s", mess) |
| 29 | } |
| 30 | |
| 31 | exp = "3 [{0 1} {0 2}]" |
| 32 | if mess, diff := diff(Tree(2, 2).String(), exp); diff { |
| 33 | t.Errorf("Tree %s", mess) |
| 34 | } |
| 35 | |
| 36 | exp = "7 [{0 1} {0 2} {1 3} {1 4} {2 5} {2 6}]" |
| 37 | if mess, diff := diff(Tree(2, 3).String(), exp); diff { |
| 38 | t.Errorf("Tree %s", mess) |
| 39 | } |
| 40 | |
| 41 | exp = "4 [{0 1} {0 2} {0 3}]" |
| 42 | if mess, diff := diff(Tree(3, 2).String(), exp); diff { |
| 43 | t.Errorf("Tree %s", mess) |
| 44 | } |
| 45 | |
| 46 | exp = "13 [{0 1} {0 2} {0 3} {1 4} {1 5} {1 6} {2 7} {2 8} {2 9} {3 10} {3 11} {3 12}]" |
| 47 | if mess, diff := diff(Tree(3, 3).String(), exp); diff { |
| 48 | t.Errorf("Tree %s", mess) |
| 49 | } |
| 50 | |
| 51 | for k := 1; k < 4; k++ { |
| 52 | for n := 0; n < 4; n++ { |
| 53 | Consistent("Tree", t, Tree(k, n)) |
| 54 | } |
| 55 | } |
| 56 | } |