Skip to content

Commit 1d9a7d0

Browse files
committed
Test more complex types.
1 parent 91189c6 commit 1d9a7d0

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

test/runtests.jl

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,29 @@ r = query(db, "SELECT mycount(TrackId) FROM PlaylistTrack")
220220
s = query(db, "SELECT count(TrackId) FROM PlaylistTrack")
221221
@test r[1] == s[1]
222222

223+
bigsum(p, c) = p + big(c)
224+
register(db, big(0), bigsum)
225+
r = query(db, "SELECT bigsum(TrackId) FROM PlaylistTrack")
226+
s = query(db, "SELECT TrackId FROM PlaylistTrack")
227+
@test r[1][1] == big(sum(s[1]))
228+
229+
query(db, "CREATE TABLE points (x INT, y INT, z INT)")
230+
query(db, "INSERT INTO points VALUES (?, ?, ?)", [1, 2, 3])
231+
query(db, "INSERT INTO points VALUES (?, ?, ?)", [4, 5, 6])
232+
query(db, "INSERT INTO points VALUES (?, ?, ?)", [7, 8, 9])
233+
type Point3D{T<:Number}
234+
x::T
235+
y::T
236+
z::T
237+
end
238+
==(a::Point3D, b::Point3D) = a.x == b.x && a.y == b.y && a.z == b.z
239+
+(a::Point3D, b::Point3D) = Point3D(a.x + b.x, a.y + b.y, a.z + b.z)
240+
sumpoint(p::Point3D, x, y, z) = p + Point3D(x, y, z)
241+
register(db, Point3D(0, 0, 0), sumpoint)
242+
r = query(db, "SELECT sumpoint(x, y, z) FROM points")
243+
@test r[1][1] == Point3D(12, 15, 18)
244+
drop(db, "points")
245+
223246
db2 = SQLiteDB()
224247
query(db2, "CREATE TABLE tab1 (r REAL, s INT)")
225248

@@ -237,7 +260,6 @@ drop(db2, "tab2", ifexists=true)
237260

238261
close(db2)
239262

240-
241263
@test size(tables(db)) == (11,1)
242264

243265
close(db)

0 commit comments

Comments
 (0)