Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gosqlite
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
gosqlite
Commits
440c681f
Commit
440c681f
authored
Apr 22, 2013
by
gwenn
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improves tests and benches.
parent
2927f44c
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
47 additions
and
7 deletions
+47
-7
bench_test.go
bench_test.go
+21
-7
stmt_test.go
stmt_test.go
+17
-0
trace_test.go
trace_test.go
+9
-0
No files found.
bench_test.go
View file @
440c681f
...
...
@@ -47,7 +47,7 @@ func BenchmarkValuesScan(b *testing.B) {
if
Must
(
cs
.
Next
())
{
cs
.
ScanValues
(
values
)
}
panicOnError
(
b
,
cs
.
Reset
())
/*panicOnError(b, */
cs
.
Reset
()
/*)*/
}
}
...
...
@@ -70,9 +70,9 @@ func BenchmarkScan(b *testing.B) {
var
sstr
string
if
Must
(
cs
.
Next
())
{
panicOnError
(
b
,
cs
.
Scan
(
&
fnum
,
&
inum
,
&
sstr
))
/*panicOnError(b, */
cs
.
Scan
(
&
fnum
,
&
inum
,
&
sstr
)
/*)*/
}
panicOnError
(
b
,
cs
.
Reset
())
/*panicOnError(b, */
cs
.
Reset
()
/*)*/
}
}
...
...
@@ -95,20 +95,33 @@ func BenchmarkNamedScan(b *testing.B) {
var
sstr
string
if
Must
(
cs
.
Next
())
{
panicOnError
(
b
,
cs
.
NamedScan
(
"float_num"
,
&
fnum
,
"int_num"
,
&
inum
,
"a_string"
,
&
sstr
))
/*panicOnError(b, */
cs
.
NamedScan
(
"float_num"
,
&
fnum
,
"int_num"
,
&
inum
,
"a_string"
,
&
sstr
)
/*)*/
}
panicOnError
(
b
,
cs
.
Reset
())
/*panicOnError(b, */
cs
.
Reset
()
/*)*/
}
}
func
BenchmarkInsert
(
b
*
testing
.
B
)
{
b
.
StopTimer
()
db
,
err
:=
Open
(
":memory:"
)
panicOnError
(
b
,
err
)
defer
db
.
Close
()
fill
(
b
,
db
,
b
.
N
)
panicOnError
(
b
,
db
.
Exec
(
"DROP TABLE IF EXISTS test"
))
panicOnError
(
b
,
db
.
Exec
(
"CREATE TABLE test (id INTEGER PRIMARY KEY NOT NULL, float_num REAL, int_num INTEGER, a_string TEXT)"
))
s
,
err
:=
db
.
Prepare
(
"INSERT INTO test (float_num, int_num, a_string) VALUES (?, ?, ?)"
)
panicOnError
(
b
,
err
)
defer
s
.
Finalize
()
b
.
StartTimer
()
panicOnError
(
b
,
db
.
Begin
())
for
i
:=
0
;
i
<
b
.
N
;
i
++
{
/*panicOnError(b, */
s
.
Exec
(
float64
(
i
)
*
float64
(
3.14
),
i
,
"hello"
)
/*)*/
}
panicOnError
(
b
,
db
.
Commit
())
}
func
BenchmarkNamedInsert
(
b
*
testing
.
B
)
{
b
.
StopTimer
()
db
,
err
:=
Open
(
":memory:"
)
panicOnError
(
b
,
err
)
defer
db
.
Close
()
...
...
@@ -120,9 +133,10 @@ func BenchmarkNamedInsert(b *testing.B) {
panicOnError
(
b
,
err
)
defer
s
.
Finalize
()
b
.
StartTimer
()
panicOnError
(
b
,
db
.
Begin
())
for
i
:=
0
;
i
<
b
.
N
;
i
++
{
panicOnError
(
b
,
s
.
NamedBind
(
":f"
,
float64
(
i
)
*
float64
(
3.14
),
":i"
,
i
,
":s"
,
"hello"
))
/*panicOnError(b, */
s
.
NamedBind
(
":f"
,
float64
(
i
)
*
float64
(
3.14
),
":i"
,
i
,
":s"
,
"hello"
)
/*)*/
Must
(
s
.
Next
())
}
panicOnError
(
b
,
db
.
Commit
())
...
...
stmt_test.go
View file @
440c681f
...
...
@@ -367,3 +367,20 @@ func TestInsertMisuse(t *testing.T) {
_
,
err
=
is
.
Insert
()
assert
(
t
,
"missing bind parameters expected"
,
err
!=
nil
)
}
func
TestScanValues
(
t
*
testing
.
T
)
{
db
:=
open
(
t
)
defer
checkClose
(
db
,
t
)
s
,
err
:=
db
.
Prepare
(
"SELECT 1, null, 0"
)
checkNoError
(
t
,
err
,
"prepare error: %s"
)
defer
checkFinalize
(
s
,
t
)
if
!
Must
(
s
.
Next
())
{
t
.
Fatal
(
"no result"
)
}
values
:=
make
([]
interface
{},
3
)
s
.
ScanValues
(
values
)
assertEquals
(
t
,
"expected %v but got %v"
,
int64
(
1
),
values
[
0
])
assertEquals
(
t
,
"expected %v but got %v"
,
nil
,
values
[
1
])
assertEquals
(
t
,
"expected %v but got %v"
,
int64
(
0
),
values
[
2
])
}
trace_test.go
View file @
440c681f
...
...
@@ -128,3 +128,12 @@ func TestTrace(t *testing.T) {
func
TestLog
(
t
*
testing
.
T
)
{
Log
(
0
,
"One message"
)
}
func
TestMemory
(
t
*
testing
.
T
)
{
used
:=
MemoryUsed
()
assert
(
t
,
"memory used"
,
used
>=
0
)
highwater
:=
MemoryHighwater
(
false
)
assert
(
t
,
"memory highwater"
,
highwater
>=
0
)
limit
:=
SoftHeapLimit
()
assert
(
t
,
"soft heap limit positive"
,
limit
>=
0
)
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment