(t *testing.T)
| 108 | } |
| 109 | |
| 110 | func TestDispenser_NextLine(t *testing.T) { |
| 111 | input := `host:port |
| 112 | dir1 arg1 |
| 113 | dir2 arg2 arg3` |
| 114 | d := NewTestDispenser(input) |
| 115 | |
| 116 | assertNextLine := func(shouldLoad bool, expectedVal string, expectedCursor int) { |
| 117 | if d.NextLine() != shouldLoad { |
| 118 | t.Errorf("NextLine(): Should load token but got false instead (val: '%s')", d.Val()) |
| 119 | } |
| 120 | if d.cursor != expectedCursor { |
| 121 | t.Errorf("NextLine(): Expected cursor to be %d, instead was %d", expectedCursor, d.cursor) |
| 122 | } |
| 123 | if val := d.Val(); val != expectedVal { |
| 124 | t.Errorf("Val(): Expected '%s' but got '%s'", expectedVal, val) |
| 125 | } |
| 126 | } |
| 127 | |
| 128 | assertNextLine(true, "host:port", 0) |
| 129 | assertNextLine(true, "dir1", 1) |
| 130 | assertNextLine(false, "dir1", 1) |
| 131 | d.Next() // arg1 |
| 132 | assertNextLine(true, "dir2", 3) |
| 133 | assertNextLine(false, "dir2", 3) |
| 134 | d.Next() // arg2 |
| 135 | assertNextLine(false, "arg2", 4) |
| 136 | d.Next() // arg3 |
| 137 | assertNextLine(false, "arg3", 5) |
| 138 | } |
| 139 | |
| 140 | func TestDispenser_NextBlock(t *testing.T) { |
| 141 | input := `foobar1 { |
nothing calls this directly
no test coverage detected