MCPcopy
hub / github.com/pquerna/ffjson / tError

Function tError

fflib/v1/lexer_test.go:271–299  ·  view source on GitHub ↗
(t *testing.T, input string, targetCount int, targetError FFErr)

Source from the content-addressed store, hash-verified

269}
270
271func 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
301func TestInvalid(t *testing.T) {
302 tError(t, `{"a": nul}`, 4, FFErr_invalid_string)

Callers 1

TestInvalidFunction · 0.85

Calls 6

WrapErrMethod · 0.95
NewFFLexerFunction · 0.85
scanToTokCountFunction · 0.85
PosWithLineMethod · 0.80
ToErrorMethod · 0.80
FatalfMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…