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

Function tInt

fflib/v1/lexer_test.go:241–262  ·  view source on GitHub ↗
(t *testing.T, input string, target int64)

Source from the content-addressed store, hash-verified

239}
240
241func tInt(t *testing.T, input string, target int64) {
242 ffl := NewFFLexer([]byte(input))
243 err := scanToTok(ffl, FFTok_integer)
244 if err != nil {
245 t.Fatalf("scanToTok failed, couldnt find int: %v input: %v", err, input)
246 }
247
248 // Bit sizes 0, 8, 16, 32, and 64 correspond to int, int8, int16, int32, and int64.
249 i64, err := strconv.ParseInt(ffl.Output.String(), 10, 64)
250 if err != nil {
251 t.Fatalf("ParseInt failed, shouldnt of: %v input: %v", err, input)
252 }
253
254 if i64 != target {
255 t.Fatalf("ffl.Output: expected i64 '%v', got: %v from: %v", target, i64, ffl.Output.String())
256 }
257
258 err = scanToTok(ffl, FFTok_eof)
259 if err != nil {
260 t.Fatalf("Failed to find EOF after int. input: %v", input)
261 }
262}
263
264func TestInt(t *testing.T) {
265 tInt(t, `{"a": 2000}`, 2000)

Callers 1

TestIntFunction · 0.85

Calls 4

NewFFLexerFunction · 0.85
scanToTokFunction · 0.85
FatalfMethod · 0.65
StringMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…