(t *testing.T)
| 138 | } |
| 139 | |
| 140 | func TestDispenser_NextBlock(t *testing.T) { |
| 141 | input := `foobar1 { |
| 142 | sub1 arg1 |
| 143 | sub2 |
| 144 | } |
| 145 | foobar2 { |
| 146 | }` |
| 147 | d := NewTestDispenser(input) |
| 148 | |
| 149 | assertNextBlock := func(shouldLoad bool, expectedCursor, expectedNesting int) { |
| 150 | if loaded := d.NextBlock(0); loaded != shouldLoad { |
| 151 | t.Errorf("NextBlock(): Should return %v but got %v", shouldLoad, loaded) |
| 152 | } |
| 153 | if d.cursor != expectedCursor { |
| 154 | t.Errorf("NextBlock(): Expected cursor to be %d, was %d", expectedCursor, d.cursor) |
| 155 | } |
| 156 | if d.nesting != expectedNesting { |
| 157 | t.Errorf("NextBlock(): Nesting should be %d, not %d", expectedNesting, d.nesting) |
| 158 | } |
| 159 | } |
| 160 | |
| 161 | assertNextBlock(false, -1, 0) |
| 162 | d.Next() // foobar1 |
| 163 | assertNextBlock(true, 2, 1) |
| 164 | assertNextBlock(true, 3, 1) |
| 165 | assertNextBlock(true, 4, 1) |
| 166 | assertNextBlock(false, 5, 0) |
| 167 | d.Next() // foobar2 |
| 168 | assertNextBlock(false, 8, 0) // empty block is as if it didn't exist |
| 169 | } |
| 170 | |
| 171 | func TestDispenser_Args(t *testing.T) { |
| 172 | var s1, s2, s3 string |
nothing calls this directly
no test coverage detected