| 2400 | } |
| 2401 | |
| 2402 | func TestRevSquash(t *testing.T) { |
| 2403 | assert(t, revSquash(` {}`) == `{}`) |
| 2404 | assert(t, revSquash(` }`) == ` }`) |
| 2405 | assert(t, revSquash(` [123]`) == `[123]`) |
| 2406 | assert(t, revSquash(` ,123,123]`) == ` ,123,123]`) |
| 2407 | assert(t, revSquash(` hello,[[true,false],[0,1,2,3,5],[123]]`) == `[[true,false],[0,1,2,3,5],[123]]`) |
| 2408 | assert(t, revSquash(` "hello"`) == `"hello"`) |
| 2409 | assert(t, revSquash(` "hel\\lo"`) == `"hel\\lo"`) |
| 2410 | assert(t, revSquash(` "hel\\"lo"`) == `"lo"`) |
| 2411 | assert(t, revSquash(` "hel\\\"lo"`) == `"hel\\\"lo"`) |
| 2412 | assert(t, revSquash(`hel\\\"lo"`) == `hel\\\"lo"`) |
| 2413 | assert(t, revSquash(`\"hel\\\"lo"`) == `\"hel\\\"lo"`) |
| 2414 | assert(t, revSquash(`\\\"hel\\\"lo"`) == `\\\"hel\\\"lo"`) |
| 2415 | assert(t, revSquash(`\\\\"hel\\\"lo"`) == `"hel\\\"lo"`) |
| 2416 | assert(t, revSquash(`hello"`) == `hello"`) |
| 2417 | json := `true,[0,1,"sadf\"asdf",{"hi":["hello","t\"\"u",{"a":"b"}]},9]` |
| 2418 | assert(t, revSquash(json) == json[5:]) |
| 2419 | assert(t, revSquash(json[:len(json)-3]) == `{"hi":["hello","t\"\"u",{"a":"b"}]}`) |
| 2420 | assert(t, revSquash(json[:len(json)-4]) == `["hello","t\"\"u",{"a":"b"}]`) |
| 2421 | assert(t, revSquash(json[:len(json)-5]) == `{"a":"b"}`) |
| 2422 | assert(t, revSquash(json[:len(json)-6]) == `"b"`) |
| 2423 | assert(t, revSquash(json[:len(json)-10]) == `"a"`) |
| 2424 | assert(t, revSquash(json[:len(json)-15]) == `"t\"\"u"`) |
| 2425 | assert(t, revSquash(json[:len(json)-24]) == `"hello"`) |
| 2426 | assert(t, revSquash(json[:len(json)-33]) == `"hi"`) |
| 2427 | assert(t, revSquash(json[:len(json)-39]) == `"sadf\"asdf"`) |
| 2428 | } |
| 2429 | |
| 2430 | const readmeJSON = ` |
| 2431 | { |