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

Function tDouble

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

Source from the content-addressed store, hash-verified

208}
209
210func tDouble(t *testing.T, input string, target float64) {
211 ffl := NewFFLexer([]byte(input))
212 err := scanToTok(ffl, FFTok_double)
213 if err != nil {
214 t.Fatalf("scanToTok failed, couldnt find double: %v input: %v", err, input)
215 }
216
217 f64, err := strconv.ParseFloat(ffl.Output.String(), 64)
218 if err != nil {
219 t.Fatalf("ParseFloat failed, shouldnt of: %v input: %v", err, input)
220 }
221
222 if int64(f64*1000) != int64(target*1000) {
223 t.Fatalf("ffl.Output: expected f64 '%v', got: %v from: %v input: %v",
224 target, f64, ffl.Output.String(), input)
225 }
226
227 err = scanToTok(ffl, FFTok_eof)
228 if err != nil {
229 t.Fatalf("Failed to find EOF after double. input: %v", input)
230 }
231}
232
233func TestDouble(t *testing.T) {
234 tDouble(t, `{"a": 1.2}`, 1.2)

Callers 1

TestDoubleFunction · 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…