Debian Codegraph @

maz-db/tests/qml/tst_put.qml

raw
1 import QtQuick 2.4
2 import QtQuick.Window 2.1
3 import QtTest 1.0
4 import MazDB 1.0
5
6 TestCase {
7 name: "MazDB::PutGet"
8 property string source: Qt.resolvedUrl("~/.maztest.db")
9
10 MazDB {
11 id: db
12 }
13
14 Rectangle {
15 id: rect
16 visible: false
17 color: "red"
18 }
19
20 function initTestCase() {
21 db.source = source
22 }
23
24 function cleanupTestCase() {
25 db.destroyDB(source)
26 }
27
28 function test_put_get_string() {
29 compare(db.opened, true, db.errorString)
30 compare(db.putSync("string", "asdf"), true, "should be ok")
31 compare(db.get("string"), "asdf")
32 }
33
34 function test_put_get_int() {
35 compare(db.opened, true, db.errorString)
36 compare(db.putSync("int", 10), true, "should be ok")
37 compare(db.get("int"), 10)
38 }
39
40 function test_put_get_double() {
41 compare(db.opened, true, db.errorString)
42 compare(db.putSync("double", 1.0), true, "should be ok")
43 compare(db.get("double"), 1.0)
44 }
45
46 function test_put_get_bool() {
47 compare(db.opened, true, db.errorString)
48 compare(db.putSync("bool", true), true, "should be ok")
49 compare(db.get("bool"), true)
50 }
51
52 function test_put_get_list() {
53 compare(db.opened, true, db.errorString)
54 compare(db.putSync("list", ["fdfd", "gpgp"]), true, "should be ok")
55 compare(db.get("list"), ["fdfd", "gpgp"])
56 }
57
58 function test_put_get_object() {
59 compare(db.opened, true, db.errorString)
60 compare(db.putSync("object", {a: "a", b: "b"}), true, "should be ok")
61 compare(db.get("object"), {a: "a", b: "b"})
62 }
63
64 function test_put_get_date() {
65 compare(db.opened, true, db.errorString)
66 var date = Date.now()
67 compare(db.putSync("date", date), true, "should be ok")
68 compare(db.get("date"), date)
69 }
70
71 function test_put_get_time() {
72 compare(db.opened, true, db.errorString)
73 var time = new Date()
74 compare(db.putSync("time", time.getTime()), true, "should be ok")
75 compare(db.get("time"), time.getTime())
76 }
77 }
78