Run go vet
Bugs found.
This commit is contained in:
parent
8118c8d3cc
commit
bf6412b55d
12 changed files with 28 additions and 14 deletions
|
|
@ -103,7 +103,7 @@ func (it *AllIterator) Next() bool {
|
||||||
} else {
|
} else {
|
||||||
k, _ := cur.Seek(last)
|
k, _ := cur.Seek(last)
|
||||||
if !bytes.Equal(k, last) {
|
if !bytes.Equal(k, last) {
|
||||||
return fmt.Errorf("could not pick up after", k)
|
return fmt.Errorf("could not pick up after %v", k)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for i < bufferSize {
|
for i < bufferSize {
|
||||||
|
|
|
||||||
|
|
@ -148,7 +148,7 @@ func (it *Iterator) Next() bool {
|
||||||
} else {
|
} else {
|
||||||
k, _ := cur.Seek(last)
|
k, _ := cur.Seek(last)
|
||||||
if !bytes.Equal(k, last) {
|
if !bytes.Equal(k, last) {
|
||||||
return fmt.Errorf("could not pick up after", k)
|
return fmt.Errorf("could not pick up after %v", k)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for i < bufferSize {
|
for i < bufferSize {
|
||||||
|
|
|
||||||
|
|
@ -100,7 +100,7 @@ func (it *Fixed) DebugString(indent int) string {
|
||||||
if len(it.values) > 0 {
|
if len(it.values) > 0 {
|
||||||
value = fmt.Sprint(it.values[0])
|
value = fmt.Sprint(it.values[0])
|
||||||
}
|
}
|
||||||
return fmt.Sprintf("%s(%s %d tags: %s Size: %d id0: %d)",
|
return fmt.Sprintf("%s(%s %d tags: %s Size: %d id0: %s)",
|
||||||
strings.Repeat(" ", indent),
|
strings.Repeat(" ", indent),
|
||||||
it.Type(),
|
it.Type(),
|
||||||
it.UID(),
|
it.UID(),
|
||||||
|
|
|
||||||
|
|
@ -154,7 +154,7 @@ func (it *Comparison) NextPath() bool {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
if it.doComparison(it.subIt.Result()) {
|
if it.doComparison(it.subIt.Result()) {
|
||||||
return true
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
it.result = it.subIt.Result()
|
it.result = it.subIt.Result()
|
||||||
|
|
|
||||||
|
|
@ -137,7 +137,12 @@ func TestLoadDatabase(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
w, _ := writer.NewSingleReplication(qs, nil)
|
w, _ := writer.NewSingleReplication(qs, nil)
|
||||||
w.AddQuad(quad.Quad{"Something", "points_to", "Something Else", "context"})
|
w.AddQuad(quad.Quad{
|
||||||
|
Subject: "Something",
|
||||||
|
Predicate: "points_to",
|
||||||
|
Object: "Something Else",
|
||||||
|
Label: "context",
|
||||||
|
})
|
||||||
for _, pq := range []string{"Something", "points_to", "Something Else", "context"} {
|
for _, pq := range []string{"Something", "points_to", "Something Else", "context"} {
|
||||||
if got := qs.NameOf(qs.ValueOf(pq)); got != pq {
|
if got := qs.NameOf(qs.ValueOf(pq)); got != pq {
|
||||||
t.Errorf("Failed to roundtrip %q, got:%q expect:%q", pq, got, pq)
|
t.Errorf("Failed to roundtrip %q, got:%q expect:%q", pq, got, pq)
|
||||||
|
|
@ -171,7 +176,12 @@ func TestLoadDatabase(t *testing.T) {
|
||||||
t.Errorf("Unexpected quadstore size, got:%d expect:5", s)
|
t.Errorf("Unexpected quadstore size, got:%d expect:5", s)
|
||||||
}
|
}
|
||||||
|
|
||||||
w.RemoveQuad(quad.Quad{"A", "follows", "B", ""})
|
w.RemoveQuad(quad.Quad{
|
||||||
|
Subject: "A",
|
||||||
|
Predicate: "follows",
|
||||||
|
Object: "B",
|
||||||
|
Label: "",
|
||||||
|
})
|
||||||
if s := qs.Size(); s != 10 {
|
if s := qs.Size(); s != 10 {
|
||||||
t.Errorf("Unexpected quadstore size after RemoveQuad, got:%d expect:10", s)
|
t.Errorf("Unexpected quadstore size after RemoveQuad, got:%d expect:10", s)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -177,7 +177,12 @@ func TestLinksToOptimization(t *testing.T) {
|
||||||
func TestRemoveQuad(t *testing.T) {
|
func TestRemoveQuad(t *testing.T) {
|
||||||
qs, w, _ := makeTestStore(simpleGraph)
|
qs, w, _ := makeTestStore(simpleGraph)
|
||||||
|
|
||||||
w.RemoveQuad(quad.Quad{"E", "follows", "F", ""})
|
w.RemoveQuad(quad.Quad{
|
||||||
|
Subject: "E",
|
||||||
|
Predicate: "follows",
|
||||||
|
Object: "F",
|
||||||
|
Label: "",
|
||||||
|
})
|
||||||
|
|
||||||
fixed := qs.FixedIterator()
|
fixed := qs.FixedIterator()
|
||||||
fixed.Add(qs.ValueOf("E"))
|
fixed.Add(qs.ValueOf("E"))
|
||||||
|
|
|
||||||
|
|
@ -644,7 +644,7 @@ func TestDecoder(t *testing.T) {
|
||||||
q, err := dec.Unmarshal()
|
q, err := dec.Unmarshal()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if err != io.EOF {
|
if err != io.EOF {
|
||||||
t.Fatalf("Failed to read document:", err)
|
t.Fatalf("Failed to read document: %v", err)
|
||||||
}
|
}
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -483,7 +483,7 @@ func TestDecoder(t *testing.T) {
|
||||||
q, err := dec.Unmarshal()
|
q, err := dec.Unmarshal()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if err != io.EOF {
|
if err != io.EOF {
|
||||||
t.Fatalf("Failed to read document:", err)
|
t.Fatalf("Failed to read document: %v", err)
|
||||||
}
|
}
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -68,7 +68,7 @@ func (q *Query) buildIteratorTreeInternal(query interface{}, path Path) (it grap
|
||||||
// Damn you, Javascript, and your lack of integer values.
|
// Damn you, Javascript, and your lack of integer values.
|
||||||
if math.Floor(t) == t {
|
if math.Floor(t) == t {
|
||||||
// Treat it like an integer.
|
// Treat it like an integer.
|
||||||
it = q.buildFixed(fmt.Sprintf("%d", t))
|
it = q.buildFixed(fmt.Sprintf("%0.f", t))
|
||||||
} else {
|
} else {
|
||||||
it = q.buildFixed(fmt.Sprintf("%f", t))
|
it = q.buildFixed(fmt.Sprintf("%f", t))
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -186,7 +186,7 @@ func TestMQL(t *testing.T) {
|
||||||
if !reflect.DeepEqual(got, expect) {
|
if !reflect.DeepEqual(got, expect) {
|
||||||
b, err := json.MarshalIndent(got, "", " ")
|
b, err := json.MarshalIndent(got, "", " ")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("unexpected JSON marshal error", err)
|
t.Fatalf("unexpected JSON marshal error: %v", err)
|
||||||
}
|
}
|
||||||
t.Errorf("Failed to %s, got: %s expected: %s", test.message, b, test.expect)
|
t.Errorf("Failed to %s, got: %s expected: %s", test.message, b, test.expect)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -269,5 +269,4 @@ func buildIteratorTree(tree *peg.ExpressionTree, qs graph.QuadStore) graph.Itera
|
||||||
default:
|
default:
|
||||||
return &iterator.Null{}
|
return &iterator.Null{}
|
||||||
}
|
}
|
||||||
panic("Not reached")
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -89,7 +89,7 @@ func TestTreeConstraintParse(t *testing.T) {
|
||||||
"($a (:is :good))))"
|
"($a (:is :good))))"
|
||||||
it := BuildIteratorTreeForQuery(qs, query)
|
it := BuildIteratorTreeForQuery(qs, query)
|
||||||
if it.Type() != graph.And {
|
if it.Type() != graph.And {
|
||||||
t.Error("Odd iterator tree. Got: %s", it.DebugString(0))
|
t.Errorf("Odd iterator tree. Got: %s", it.DebugString(0))
|
||||||
}
|
}
|
||||||
if !graph.Next(it) {
|
if !graph.Next(it) {
|
||||||
t.Error("Got no results")
|
t.Error("Got no results")
|
||||||
|
|
@ -137,7 +137,7 @@ func TestMultipleConstraintParse(t *testing.T) {
|
||||||
)`
|
)`
|
||||||
it := BuildIteratorTreeForQuery(qs, query)
|
it := BuildIteratorTreeForQuery(qs, query)
|
||||||
if it.Type() != graph.And {
|
if it.Type() != graph.And {
|
||||||
t.Error("Odd iterator tree. Got: %s", it.DebugString(0))
|
t.Errorf("Odd iterator tree. Got: %s", it.DebugString(0))
|
||||||
}
|
}
|
||||||
if !graph.Next(it) {
|
if !graph.Next(it) {
|
||||||
t.Error("Got no results")
|
t.Error("Got no results")
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue