summaryrefslogtreecommitdiffstats
path: root/third_party/sqlite/src/test/recover1.test
diff options
context:
space:
mode:
Diffstat (limited to 'third_party/sqlite/src/test/recover1.test')
-rw-r--r--third_party/sqlite/src/test/recover1.test91
1 files changed, 91 insertions, 0 deletions
diff --git a/third_party/sqlite/src/test/recover1.test b/third_party/sqlite/src/test/recover1.test
index c3541b7..1d90f09 100644
--- a/third_party/sqlite/src/test/recover1.test
+++ b/third_party/sqlite/src/test/recover1.test
@@ -335,4 +335,95 @@ do_test recover-types-7.0 {
execsql {SELECT rowid, value FROM integers_recover}
} {1 0 2 1 3 2 4 -2 5 127 6 -128 7 12345 8 -12345 9 32767 10 -32768 11 1234567 12 -1234567 13 8388607 14 -8388608 15 1234567890 16 -1234567890 17 2147483647 18 -2147483648 19 123456789012345 20 -123456789012345 21 140737488355327 22 -140737488355328 23 9223372036854775807 24 -9223372036854775808}
+# If UTF16 support is disabled, ignore the rest of the tests.
+#
+ifcapable {!utf16} {
+ finish_test
+ return
+}
+
+# Baseline UTF-8.
+file delete -force test.db
+sqlite3 db test.db;
+db eval {
+ PRAGMA encoding = 'UTF-8';
+}
+
+do_test recover-encoding-1.0 {
+ execsql {
+ DROP TABLE IF EXISTS e;
+ CREATE TABLE e (v TEXT);
+ INSERT INTO e VALUES('Mjollnir');
+ INSERT INTO e VALUES('Mjölnir');
+ INSERT INTO e VALUES('Mjǫlnir');
+ INSERT INTO e VALUES('Mjölner');
+ INSERT INTO e VALUES('Mjølner');
+ INSERT INTO e VALUES('ハンマー');
+ PRAGMA encoding;
+
+ DROP TABLE IF EXISTS e_recover;
+ CREATE VIRTUAL TABLE temp.e_recover USING recover(
+ e,
+ v TEXT
+ );
+ SELECT rowid, v FROM e_recover ORDER BY rowid;
+ }
+} {UTF-8 1 Mjollnir 2 Mjölnir 3 Mjǫlnir 4 Mjölner 5 Mjølner 6 ハンマー}
+
+# Reset the database to UTF-16LE.
+file delete -force test.db
+sqlite3 db test.db;
+db eval {
+ PRAGMA encoding = 'UTF-16LE';
+}
+
+do_test recover-encoding-2.0 {
+ execsql {
+ DROP TABLE IF EXISTS e;
+ CREATE TABLE e (v TEXT);
+ INSERT INTO e VALUES('Mjollnir');
+ INSERT INTO e VALUES('Mjölnir');
+ INSERT INTO e VALUES('Mjǫlnir');
+ INSERT INTO e VALUES('Mjölner');
+ INSERT INTO e VALUES('Mjølner');
+ INSERT INTO e VALUES('ハンマー');
+ PRAGMA encoding;
+
+ DROP TABLE IF EXISTS e_recover;
+ CREATE VIRTUAL TABLE temp.e_recover USING recover(
+ e,
+ v TEXT
+ );
+ SELECT rowid, v FROM e_recover ORDER BY rowid;
+ }
+} {UTF-16le 1 Mjollnir 2 Mjölnir 3 Mjǫlnir 4 Mjölner 5 Mjølner 6 ハンマー}
+
+# Reset the database to UTF-16BE.
+file delete -force test.db
+sqlite3 db test.db;
+db eval {
+ PRAGMA encoding = 'UTF-16BE';
+}
+
+do_test recover-encoding-3.0 {
+ execsql {
+ DROP TABLE IF EXISTS e;
+ CREATE TABLE e (v TEXT);
+ INSERT INTO e VALUES('Mjollnir');
+ INSERT INTO e VALUES('Mjölnir');
+ INSERT INTO e VALUES('Mjǫlnir');
+ INSERT INTO e VALUES('Mjölner');
+ INSERT INTO e VALUES('Mjølner');
+ INSERT INTO e VALUES('ハンマー');
+ PRAGMA encoding;
+
+ DROP TABLE IF EXISTS e_recover;
+ CREATE VIRTUAL TABLE temp.e_recover USING recover(
+ e,
+ v TEXT
+ );
+ SELECT rowid, v FROM e_recover ORDER BY rowid;
+ }
+} {UTF-16be 1 Mjollnir 2 Mjölnir 3 Mjǫlnir 4 Mjölner 5 Mjølner 6 ハンマー}
+
finish_test