minor format updates

This commit is contained in:
Josh Baker 2017-04-10 11:41:19 -07:00
parent 20d521de6e
commit 635226ae42
2 changed files with 21 additions and 29 deletions

View File

@ -905,7 +905,7 @@ func parseObject(c *parseContext, i int, path string) (int, bool) {
break break
} }
} }
i, key, kesc, ok = i, c.json[s:], false, false key, kesc, ok = c.json[s:], false, false
parse_key_string_done: parse_key_string_done:
break break
} }
@ -1223,16 +1223,15 @@ func parseArray(c *parseContext, i int, path string) (int, bool) {
c.value.Type = JSON c.value.Type = JSON
c.value.Raw = string(jsons) c.value.Raw = string(jsons)
return i + 1, true return i + 1, true
} else {
if rp.alogok {
break
}
c.value.Raw = val
c.value.Type = Number
c.value.Num = float64(h - 1)
c.calcd = true
return i + 1, true
} }
if rp.alogok {
break
}
c.value.Raw = val
c.value.Type = Number
c.value.Num = float64(h - 1)
c.calcd = true
return i + 1, true
} }
if len(multires) > 0 && !c.value.Exists() { if len(multires) > 0 && !c.value.Exists() {
c.value = Result{ c.value = Result{

View File

@ -244,19 +244,19 @@ func TestBasic(t *testing.T) {
} }
var token Result var token Result
if token = Parse("-102"); token.Num != -102 { if token = Parse("-102"); token.Num != -102 {
t.Fatal("expected %v, got %v", -102, token.Num) t.Fatalf("expected %v, got %v", -102, token.Num)
} }
if token = Parse("102"); token.Num != 102 { if token = Parse("102"); token.Num != 102 {
t.Fatal("expected %v, got %v", 102, token.Num) t.Fatalf("expected %v, got %v", 102, token.Num)
} }
if token = Parse("102.2"); token.Num != 102.2 { if token = Parse("102.2"); token.Num != 102.2 {
t.Fatal("expected %v, got %v", 102.2, token.Num) t.Fatalf("expected %v, got %v", 102.2, token.Num)
} }
if token = Parse(`"hello"`); token.Str != "hello" { if token = Parse(`"hello"`); token.Str != "hello" {
t.Fatal("expected %v, got %v", "hello", token.Str) t.Fatalf("expected %v, got %v", "hello", token.Str)
} }
if token = Parse(`"\"he\nllo\""`); token.Str != "\"he\nllo\"" { if token = Parse(`"\"he\nllo\""`); token.Str != "\"he\nllo\"" {
t.Fatal("expected %v, got %v", "\"he\nllo\"", token.Str) t.Fatalf("expected %v, got %v", "\"he\nllo\"", token.Str)
} }
mtok = get(basicJSON, "loggy.programmers.#.firstName") mtok = get(basicJSON, "loggy.programmers.#.firstName")
if len(mtok.Array()) != 4 { if len(mtok.Array()) != 4 {
@ -269,7 +269,7 @@ func TestBasic(t *testing.T) {
} }
mtok = get(basicJSON, "loggy.programmers.#.asd") mtok = get(basicJSON, "loggy.programmers.#.asd")
if mtok.Type != JSON { if mtok.Type != JSON {
t.Fatal("expected %v, got %v", JSON, mtok.Type) t.Fatalf("expected %v, got %v", JSON, mtok.Type)
} }
if len(mtok.Array()) != 0 { if len(mtok.Array()) != 0 {
t.Fatalf("expected 0, got %v", len(mtok.Array())) t.Fatalf("expected 0, got %v", len(mtok.Array()))
@ -518,17 +518,17 @@ func TestSingleArrayValue(t *testing.T) {
t.Fatal("array is empty") t.Fatal("array is empty")
} }
if array[0].String() != "value" { if array[0].String() != "value" {
t.Fatal("got %s, should be %s", array[0].String(), "value") t.Fatalf("got %s, should be %s", array[0].String(), "value")
} }
array = Get(json, "key2.#").Array() array = Get(json, "key2.#").Array()
if len(array) != 1 { if len(array) != 1 {
t.Fatal("got '%v', expected '%v'", len(array), 1) t.Fatalf("got '%v', expected '%v'", len(array), 1)
} }
array = Get(json, "key3").Array() array = Get(json, "key3").Array()
if len(array) != 0 { if len(array) != 0 {
t.Fatal("got '%v', expected '%v'", len(array), 0) t.Fatalf("got '%v', expected '%v'", len(array), 0)
} }
} }
@ -570,10 +570,9 @@ func TestManyBasic(t *testing.T) {
if fmt.Sprintf("%v", results) != expect { if fmt.Sprintf("%v", results) != expect {
t.Fatalf("expected %v, got %v", expect, results) t.Fatalf("expected %v, got %v", expect, results)
} }
return //if testLastWasFallback != shouldFallback {
if testLastWasFallback != shouldFallback { // t.Fatalf("expected %v, got %v", shouldFallback, testLastWasFallback)
t.Fatalf("expected %v, got %v", shouldFallback, testLastWasFallback) //}
}
} }
testMany(false, "[Point]", "position.type") testMany(false, "[Point]", "position.type")
testMany(false, `[emptya ["world peace"] 31]`, ".a", "loves", "age") testMany(false, `[emptya ["world peace"] 31]`, ".a", "loves", "age")
@ -724,12 +723,6 @@ func BenchmarkGJSONGetMany64Paths(t *testing.B) {
func BenchmarkGJSONGetMany128Paths(t *testing.B) { func BenchmarkGJSONGetMany128Paths(t *testing.B) {
benchmarkGJSONGetManyN(t, 128) benchmarkGJSONGetManyN(t, 128)
} }
func BenchmarkGJSONGetMany256Paths(t *testing.B) {
benchmarkGJSONGetManyN(t, 256)
}
func BenchmarkGJSONGetMany512Paths(t *testing.B) {
benchmarkGJSONGetManyN(t, 512)
}
func benchmarkGJSONGetManyN(t *testing.B, n int) { func benchmarkGJSONGetManyN(t *testing.B, n int) {
var paths []string var paths []string
for len(paths) < n { for len(paths) < n {