2
Copyright (C) 2015 Christian Dywan <christian@twotoasts.de>
4
This library is free software; you can redistribute it and/or
5
modify it under the terms of the GNU Lesser General Public
6
License as published by the Free Software Foundation; either
7
version 2.1 of the License, or (at your option) any later version.
9
See the file COPYING for the full license text.
12
class DatabaseTest : Midori.Test.Job {
13
public static void test () { new DatabaseTest ().run_sync (); }
14
public override async void run (Cancellable cancellable) throws GLib.Error {
15
var database = new Midori.Database ();
16
database.exec ("CREATE TABLE cats (cat text, favorite text)");
17
database.exec ("INSERT INTO cats (cat, favorite) VALUES ('Henry', 'pillow')");
18
var statement = database.prepare ("SELECT cat FROM cats WHERE favorite = :toy");
19
/* Missing : should throw an error */
21
statement.bind ("toy", typeof (string), "pillow");
22
} catch (Midori.DatabaseError error) {
23
Katze.assert_str_equal (statement.query, error.message,
24
"No such parameter 'toy' in statement: " + statement.query);
26
statement.bind (":toy", typeof (string), "pillow");
30
void main (string[] args) {
31
Midori.Test.init (ref args);
32
Midori.App.setup (ref args, null);
33
Midori.Paths.init (Midori.RuntimeMode.NORMAL, null);
34
Test.add_func ("/database/bind", DatabaseTest.test);