Run go vet

Bugs found.
This commit is contained in:
kortschak 2014-08-28 12:22:37 +09:30
parent 8118c8d3cc
commit bf6412b55d
12 changed files with 28 additions and 14 deletions

View file

@ -103,7 +103,7 @@ func (it *AllIterator) Next() bool {
} else {
k, _ := cur.Seek(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 {

View file

@ -148,7 +148,7 @@ func (it *Iterator) Next() bool {
} else {
k, _ := cur.Seek(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 {

View file

@ -100,7 +100,7 @@ func (it *Fixed) DebugString(indent int) string {
if len(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),
it.Type(),
it.UID(),

View file

@ -154,7 +154,7 @@ func (it *Comparison) NextPath() bool {
return false
}
if it.doComparison(it.subIt.Result()) {
return true
break
}
}
it.result = it.subIt.Result()

View file

@ -137,7 +137,12 @@ func TestLoadDatabase(t *testing.T) {
}
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"} {
if got := qs.NameOf(qs.ValueOf(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)
}
w.RemoveQuad(quad.Quad{"A", "follows", "B", ""})
w.RemoveQuad(quad.Quad{
Subject: "A",
Predicate: "follows",
Object: "B",
Label: "",
})
if s := qs.Size(); s != 10 {
t.Errorf("Unexpected quadstore size after RemoveQuad, got:%d expect:10", s)
}

View file

@ -177,7 +177,12 @@ func TestLinksToOptimization(t *testing.T) {
func TestRemoveQuad(t *testing.T) {
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.Add(qs.ValueOf("E"))

View file

@ -644,7 +644,7 @@ func TestDecoder(t *testing.T) {
q, err := dec.Unmarshal()
if err != nil {
if err != io.EOF {
t.Fatalf("Failed to read document:", err)
t.Fatalf("Failed to read document: %v", err)
}
break
}

View file

@ -483,7 +483,7 @@ func TestDecoder(t *testing.T) {
q, err := dec.Unmarshal()
if err != nil {
if err != io.EOF {
t.Fatalf("Failed to read document:", err)
t.Fatalf("Failed to read document: %v", err)
}
break
}

View file

@ -68,7 +68,7 @@ func (q *Query) buildIteratorTreeInternal(query interface{}, path Path) (it grap
// Damn you, Javascript, and your lack of integer values.
if math.Floor(t) == t {
// Treat it like an integer.
it = q.buildFixed(fmt.Sprintf("%d", t))
it = q.buildFixed(fmt.Sprintf("%0.f", t))
} else {
it = q.buildFixed(fmt.Sprintf("%f", t))
}

View file

@ -186,7 +186,7 @@ func TestMQL(t *testing.T) {
if !reflect.DeepEqual(got, expect) {
b, err := json.MarshalIndent(got, "", " ")
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)
}

View file

@ -269,5 +269,4 @@ func buildIteratorTree(tree *peg.ExpressionTree, qs graph.QuadStore) graph.Itera
default:
return &iterator.Null{}
}
panic("Not reached")
}

View file

@ -89,7 +89,7 @@ func TestTreeConstraintParse(t *testing.T) {
"($a (:is :good))))"
it := BuildIteratorTreeForQuery(qs, query)
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) {
t.Error("Got no results")
@ -137,7 +137,7 @@ func TestMultipleConstraintParse(t *testing.T) {
)`
it := BuildIteratorTreeForQuery(qs, query)
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) {
t.Error("Got no results")