Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4)

Unified Diff: third_party/sqlite/src/test/fkey3.test

Issue 6990047: Import SQLite 3.7.6.3. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/sqlite/src/test/fkey2.test ('k') | third_party/sqlite/src/test/fkey4.test » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/sqlite/src/test/fkey3.test
diff --git a/third_party/sqlite/src/test/fkey3.test b/third_party/sqlite/src/test/fkey3.test
new file mode 100644
index 0000000000000000000000000000000000000000..88b5aad370e225b42634e542f1107cb6c972fe7e
--- /dev/null
+++ b/third_party/sqlite/src/test/fkey3.test
@@ -0,0 +1,80 @@
+# 2009 September 15
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library.
+#
+# This file implements tests for foreign keys.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+ifcapable {!foreignkey||!trigger} {
+ finish_test
+ return
+}
+
+# Create a table and some data to work with.
+#
+do_test fkey3-1.1 {
+ execsql {
+ PRAGMA foreign_keys=ON;
+ CREATE TABLE t1(x INTEGER PRIMARY KEY);
+ INSERT INTO t1 VALUES(100);
+ INSERT INTO t1 VALUES(101);
+ CREATE TABLE t2(y INTEGER REFERENCES t1 (x));
+ INSERT INTO t2 VALUES(100);
+ INSERT INTO t2 VALUES(101);
+ SELECT 1, x FROM t1;
+ SELECT 2, y FROM t2;
+ }
+} {1 100 1 101 2 100 2 101}
+
+do_test fkey3-1.2 {
+ catchsql {
+ DELETE FROM t1 WHERE x=100;
+ }
+} {1 {foreign key constraint failed}}
+
+do_test fkey3-1.3 {
+ catchsql {
+ DROP TABLE t1;
+ }
+} {1 {foreign key constraint failed}}
+
+do_test fkey3-1.4 {
+ execsql {
+ DROP TABLE t2;
+ }
+} {}
+
+do_test fkey3-1.5 {
+ execsql {
+ DROP TABLE t1;
+ }
+} {}
+
+do_test fkey3-2.1 {
+ execsql {
+ PRAGMA foreign_keys=ON;
+ CREATE TABLE t1(x INTEGER PRIMARY KEY);
+ INSERT INTO t1 VALUES(100);
+ INSERT INTO t1 VALUES(101);
+ CREATE TABLE t2(y INTEGER PRIMARY KEY REFERENCES t1 (x) ON UPDATE SET NULL);
+ }
+ execsql {
+ INSERT INTO t2 VALUES(100);
+ INSERT INTO t2 VALUES(101);
+ SELECT 1, x FROM t1;
+ SELECT 2, y FROM t2;
+ }
+} {1 100 1 101 2 100 2 101}
+
+finish_test
« no previous file with comments | « third_party/sqlite/src/test/fkey2.test ('k') | third_party/sqlite/src/test/fkey4.test » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698