diff options
author | Klaas Freitag <freitag@owncloud.com> | 2014-10-16 23:21:47 +0400 |
---|---|---|
committer | Klaas Freitag <freitag@owncloud.com> | 2014-10-16 23:21:47 +0400 |
commit | 2f740fe4718751cb8e4d49d10cb2d44778cd54a8 (patch) | |
tree | b93f731ed795bf29672ea12a88efd0a7036af78f /test | |
parent | b1c10c845404b050e7b5ab1dd39a47cad7c1c262 (diff) |
tests: Added unicode read an write testcase for ownsql.
Diffstat (limited to 'test')
-rw-r--r-- | test/testownsql.h | 35 |
1 files changed, 30 insertions, 5 deletions
diff --git a/test/testownsql.h b/test/testownsql.h index f9dfaa6ea..c3f79f4d6 100644 --- a/test/testownsql.h +++ b/test/testownsql.h @@ -76,13 +76,13 @@ private slots: void testInsert2() { const char *sql = "INSERT INTO addresses (id, name, address, entered) VALUES " - "(?0, ?1, ?2, ?3);"; + "(?1, ?2, ?3, ?4);"; SqlQuery q(_db); q.prepare(sql); - q.bindValue(0, 2); - q.bindValue(1, "Brucely Lafayette"); - q.bindValue(2, "Nurderway5, New York"); - q.bindValue(3, 1403101224); + q.bindValue(1, 2); + q.bindValue(2, "Brucely Lafayette"); + q.bindValue(3, "Nurderway5, New York"); + q.bindValue(4, 1403101224); QVERIFY(q.exec()); } @@ -123,6 +123,31 @@ private slots: } } + void testUnicode() { + const char *sql = "INSERT INTO addresses (id, name, address, entered) VALUES " + "(?1, ?2, ?3, ?4);"; + SqlQuery q(_db); + q.prepare(sql); + q.bindValue(1, 3); + q.bindValue(2, QString::fromUtf8("пятницы")); + q.bindValue(3, QString::fromUtf8("проспект")); + q.bindValue(4, 1403002224); + QVERIFY(q.exec()); + } + + void testReadUnicode() { + const char *sql = "SELECT * FROM addresses WHERE id=3;"; + SqlQuery q(_db); + q.prepare(sql); + + if(q.next()) { + QString name = q.stringValue(1); + QString address = q.stringValue(2); + QVERIFY( name == QString::fromUtf8("пятницы") ); + QVERIFY( address == QString::fromUtf8("проспект")); + } + } + private: SqlDatabase _db; }; |