summaryrefslogtreecommitdiffstats
path: root/storage/test/unit/test_unicode.js
diff options
context:
space:
mode:
authorMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
committerMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
commit5f8de423f190bbb79a62f804151bc24824fa32d8 (patch)
tree10027f336435511475e392454359edea8e25895d /storage/test/unit/test_unicode.js
parent49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff)
downloadUXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip
Add m-esr52 at 52.6.0
Diffstat (limited to 'storage/test/unit/test_unicode.js')
-rw-r--r--storage/test/unit/test_unicode.js83
1 files changed, 83 insertions, 0 deletions
diff --git a/storage/test/unit/test_unicode.js b/storage/test/unit/test_unicode.js
new file mode 100644
index 000000000..7753bbfdb
--- /dev/null
+++ b/storage/test/unit/test_unicode.js
@@ -0,0 +1,83 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+// This file tests the unicode functions that we have added
+
+const LATIN1_AE = "\xc6"; // "Æ"
+const LATIN1_ae = "\xe6"; // "æ"
+
+add_task(function* setup() {
+ getOpenedDatabase().createTable("test", "id INTEGER PRIMARY KEY, name TEXT");
+
+ var stmt = createStatement("INSERT INTO test (name, id) VALUES (?1, ?2)");
+ stmt.bindByIndex(0, LATIN1_AE);
+ stmt.bindByIndex(1, 1);
+ stmt.execute();
+ stmt.bindByIndex(0, "A");
+ stmt.bindByIndex(1, 2);
+ stmt.execute();
+ stmt.bindByIndex(0, "b");
+ stmt.bindByIndex(1, 3);
+ stmt.execute();
+ stmt.bindByIndex(0, LATIN1_ae);
+ stmt.bindByIndex(1, 4);
+ stmt.execute();
+ stmt.finalize();
+
+ do_register_cleanup(cleanup);
+});
+
+add_task(function* test_upper_ascii() {
+ var stmt = createStatement("SELECT name, id FROM test WHERE name = upper('a')");
+ do_check_true(stmt.executeStep());
+ do_check_eq("A", stmt.getString(0));
+ do_check_eq(2, stmt.getInt32(1));
+ stmt.reset();
+ stmt.finalize();
+});
+
+add_task(function* test_upper_non_ascii() {
+ var stmt = createStatement("SELECT name, id FROM test WHERE name = upper(?1)");
+ stmt.bindByIndex(0, LATIN1_ae);
+ do_check_true(stmt.executeStep());
+ do_check_eq(LATIN1_AE, stmt.getString(0));
+ do_check_eq(1, stmt.getInt32(1));
+ stmt.reset();
+ stmt.finalize();
+});
+
+add_task(function* test_lower_ascii() {
+ var stmt = createStatement("SELECT name, id FROM test WHERE name = lower('B')");
+ do_check_true(stmt.executeStep());
+ do_check_eq("b", stmt.getString(0));
+ do_check_eq(3, stmt.getInt32(1));
+ stmt.reset();
+ stmt.finalize();
+});
+
+add_task(function* test_lower_non_ascii() {
+ var stmt = createStatement("SELECT name, id FROM test WHERE name = lower(?1)");
+ stmt.bindByIndex(0, LATIN1_AE);
+ do_check_true(stmt.executeStep());
+ do_check_eq(LATIN1_ae, stmt.getString(0));
+ do_check_eq(4, stmt.getInt32(1));
+ stmt.reset();
+ stmt.finalize();
+});
+
+add_task(function* test_like_search_different() {
+ var stmt = createStatement("SELECT COUNT(*) FROM test WHERE name LIKE ?1");
+ stmt.bindByIndex(0, LATIN1_AE);
+ do_check_true(stmt.executeStep());
+ do_check_eq(2, stmt.getInt32(0));
+ stmt.finalize();
+});
+
+add_task(function* test_like_search_same() {
+ var stmt = createStatement("SELECT COUNT(*) FROM test WHERE name LIKE ?1");
+ stmt.bindByIndex(0, LATIN1_ae);
+ do_check_true(stmt.executeStep());
+ do_check_eq(2, stmt.getInt32(0));
+ stmt.finalize();
+});