-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsql_test.go
More file actions
36 lines (31 loc) · 721 Bytes
/
sql_test.go
File metadata and controls
36 lines (31 loc) · 721 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package pgx_test
import (
"strconv"
"testing"
"github.com/jackc/pgx"
)
func TestQueryArgs(t *testing.T) {
var qa pgx.QueryArgs
for i := 1; i < 512; i++ {
expectedPlaceholder := "$" + strconv.Itoa(i)
placeholder := qa.Append(i)
if placeholder != expectedPlaceholder {
t.Errorf(`Expected qa.Append to return "%s", but it returned "%s"`, expectedPlaceholder, placeholder)
}
}
}
func BenchmarkQueryArgs(b *testing.B) {
for i := 0; i < b.N; i++ {
qa := pgx.QueryArgs(make([]interface{}, 0, 16))
qa.Append("foo1")
qa.Append("foo2")
qa.Append("foo3")
qa.Append("foo4")
qa.Append("foo5")
qa.Append("foo6")
qa.Append("foo7")
qa.Append("foo8")
qa.Append("foo9")
qa.Append("foo10")
}
}