(t *testing.T, input string, targetCount int, targetError FFErr)
| 269 | } |
| 270 | |
| 271 | func tError(t *testing.T, input string, targetCount int, targetError FFErr) { |
| 272 | ffl := NewFFLexer([]byte(input)) |
| 273 | count, err := scanToTokCount(ffl, FFTok_error) |
| 274 | if err != nil { |
| 275 | t.Fatalf("scanToTok failed, couldnt find error token: %v input: %v", err, input) |
| 276 | } |
| 277 | |
| 278 | if count != targetCount { |
| 279 | t.Fatalf("Expected error token at offset %v, but found it at %v input: %v", |
| 280 | count, targetCount, input) |
| 281 | } |
| 282 | |
| 283 | if ffl.Error != targetError { |
| 284 | t.Fatalf("Expected error token %v, but got %v input: %v", |
| 285 | targetError, ffl.Error, input) |
| 286 | } |
| 287 | |
| 288 | line, char := ffl.reader.PosWithLine() |
| 289 | if line == 0 || char == 0 { |
| 290 | t.Fatalf("ffl.PosWithLine(): expected >=0 values. line=%v char=%v", |
| 291 | line, char) |
| 292 | } |
| 293 | |
| 294 | berr := ffl.WrapErr(ffl.Error.ToError()) |
| 295 | if berr == nil { |
| 296 | t.Fatalf("expected error") |
| 297 | } |
| 298 | |
| 299 | } |
| 300 | |
| 301 | func TestInvalid(t *testing.T) { |
| 302 | tError(t, `{"a": nul}`, 4, FFErr_invalid_string) |
no test coverage detected
searching dependent graphs…