@@ -314,7 +314,8 @@ func TestValueGetTyped(t *testing.T) {
314
314
"zero_float2": -0e123,
315
315
"inf_float": Inf,
316
316
"minus_inf_float": -Inf,
317
- "nan": nan
317
+ "nan": nan,
318
+ "tiny_number": 0.0000000005
318
319
}` )
319
320
if err != nil {
320
321
t .Fatalf ("unexpected error: %s" , err )
@@ -360,7 +361,7 @@ func TestValueGetTyped(t *testing.T) {
360
361
t .Fatalf ("unexpected value; got %d; want %d" , n , 123 )
361
362
}
362
363
n64 := v .GetInt64 ("foo" )
363
- if n != 123 {
364
+ if n64 != 123 {
364
365
t .Fatalf ("unexpected value; got %d; want %d" , n64 , 123 )
365
366
}
366
367
un := v .GetUint ("foo" )
@@ -371,22 +372,30 @@ func TestValueGetTyped(t *testing.T) {
371
372
if un != 123 {
372
373
t .Fatalf ("unexpected value; got %d; want %d" , un64 , 123 )
373
374
}
375
+ nstr := v .GetNumberAsStringBytes ("foo" )
376
+ if b2s (nstr ) != "123" {
377
+ t .Fatalf ("unexpected value; got %s; want %s" , nstr , "123" )
378
+ }
374
379
n = v .GetInt ("bar" )
375
380
if n != 0 {
376
381
t .Fatalf ("unexpected non-zero value; got %d" , n )
377
382
}
378
383
n64 = v .GetInt64 ("bar" )
379
- if n != 0 {
384
+ if n64 != 0 {
380
385
t .Fatalf ("unexpected non-zero value; got %d" , n64 )
381
386
}
382
387
un = v .GetUint ("bar" )
383
- if n != 0 {
388
+ if un != 0 {
384
389
t .Fatalf ("unexpected non-zero value; got %d" , un )
385
390
}
386
391
un64 = v .GetUint64 ("bar" )
387
- if n != 0 {
392
+ if un64 != 0 {
388
393
t .Fatalf ("unexpected non-zero value; got %d" , un64 )
389
394
}
395
+ nstr = v .GetNumberAsStringBytes ("bar" )
396
+ if nstr != nil {
397
+ t .Fatalf ("unexpected non-nil value; got %d" , nstr )
398
+ }
390
399
f := v .GetFloat64 ("foo" )
391
400
if f != 123.0 {
392
401
t .Fatalf ("unexpected value; got %f; want %f" , f , 123.0 )
@@ -464,6 +473,11 @@ func TestValueGetTyped(t *testing.T) {
464
473
if ! math .IsNaN (nanf ) {
465
474
t .Fatalf ("unexpected nan value: %f. Expecting %f" , nanf , math .NaN ())
466
475
}
476
+
477
+ tiny_number := v .GetNumberAsStringBytes ("tiny_number" )
478
+ if b2s (tiny_number ) != "0.0000000005" {
479
+ t .Fatalf ("unexpected tiny_number value; got %s; want %s" , tiny_number , "0.0000000005" )
480
+ }
467
481
}
468
482
469
483
func TestVisitNil (t * testing.T ) {
0 commit comments