(t *testing.T)
| 405 | assert(t, (Result{Type: Number, Num: 1}).Float() == 1) |
| 406 | } |
| 407 | func TestForEach(t *testing.T) { |
| 408 | Result{}.ForEach(nil) |
| 409 | Result{Type: String, Str: "Hello"}.ForEach(func(_, value Result) bool { |
| 410 | assert(t, value.String() == "Hello") |
| 411 | return false |
| 412 | }) |
| 413 | Result{Type: JSON, Raw: "*invalid*"}.ForEach(nil) |
| 414 | |
| 415 | json := ` {"name": {"first": "Janet","last": "Prichard"}, |
| 416 | "asd\nf":"\ud83d\udd13","age": 47}` |
| 417 | var count int |
| 418 | ParseBytes([]byte(json)).ForEach(func(key, value Result) bool { |
| 419 | count++ |
| 420 | return true |
| 421 | }) |
| 422 | assert(t, count == 3) |
| 423 | ParseBytes([]byte(`{"bad`)).ForEach(nil) |
| 424 | ParseBytes([]byte(`{"ok":"bad`)).ForEach(nil) |
| 425 | } |
| 426 | func TestMap(t *testing.T) { |
| 427 | assert(t, len(ParseBytes([]byte(`"asdf"`)).Map()) == 0) |
| 428 | assert(t, ParseBytes([]byte(`{"asdf":"ghjk"`)).Map()["asdf"].String() == |
nothing calls this directly
no test coverage detected
searching dependent graphs…