Skip to content

Commit

Permalink
quick test of u2013 / u2019 ref: #739
Browse files Browse the repository at this point in the history
  • Loading branch information
Christopher J. Brody committed Jan 22, 2018
1 parent eedd1e9 commit cecd62b
Show file tree
Hide file tree
Showing 2 changed files with 308 additions and 9 deletions.
193 changes: 186 additions & 7 deletions spec/www/spec/db-tx-string-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -903,14 +903,193 @@ var mytests = function() {

// NOTE: the next 3 tests repeat the above for UNICODE \u2029 paragraph separator
// on iOS/macOS/Android:
// - UNICODE \u2029 paragraph separator from JavaScript to native (Objective-C/Java) is working OK
// - UNICODE \u2029 paragraph separator from native (Objective-C/Java) to JavaScript is BROKEN
// For reference:
// - litehelpers/Cordova-sqlite-storage#147
// - Apache Cordova CB-9435 (issue with cordova-ios, also affects macOS)
// - cordova/cordova-discuss#57 (issue with cordova-android)
// XXX XXX

it(suiteName + "UNICODE \\u2013 xxx string length", function(done) {
if (isWP8) pending('BROKEN on WP(8)'); // [BUG #202] Certain UNICODE characters not working with WP(8)

// NOTE: this test verifies that the UNICODE xxx (\u2013)
// is seen by the sqlite implementation OK:
var db = openDatabase("UNICODE-paragraph-separator-string-length.db", "1.0", "Demo", DEFAULT_SIZE);

expect(db).toBeDefined();

db.transaction(function(tx) {
expect(tx).toBeDefined();

var text = 'Abcd\u20191234';
tx.executeSql("select length(?) AS stringlength", ['First\u2013Second'], function (tx_ignored, rs) {
expect(rs.rows.item(0).stringlength).toBe(12);

// Close (plugin only) & finish:
(isWebSql) ? done() : db.close(done, done);
});
}, function(error) {
// NOT EXPECTED:
expect(false).toBe(true);
expect(error.message).toBe('--');
// Close (plugin only) & finish:
(isWebSql) ? done() : db.close(done, done);
});
}, MYTIMEOUT);

it(suiteName + 'HEX value of string with UNICODE \\u2013 xxx', function(done) {
// NOTE: this test verifies that the UNICODE xxx (\u2013)
// is seen by the sqlite implementation OK:
var db = openDatabase("UNICODE-paragraph-separator-hex-value-test.db", "1.0", "Demo", DEFAULT_SIZE);

expect(db).toBeDefined();

db.transaction(function(tx) {
expect(tx).toBeDefined();

tx.executeSql('SELECT HEX(?) AS myresult', ['1\u2013'], function (tx_ignored, rs) {
if (isWindows)
expect(rs.rows.item(0).myresult).toBe('31002920'); // (UTF-16le)
else
expect(rs.rows.item(0).myresult).toBe('31E28093'); // (UTF-8)

// Close (plugin only) & finish:
(isWebSql) ? done() : db.close(done, done);
});
}, function(error) {
// NOT EXPECTED:
expect(false).toBe(true);
expect(error.message).toBe('--');
// Close (plugin only) & finish:
(isWebSql) ? done() : db.close(done, done);
});
}, MYTIMEOUT);

it(suiteName + ' handles UNICODE \\u2013 xxx correctly [string test]', function (done) {
if (isWP8) pending('BROKEN on WP(8)'); // [BUG #202] UNICODE characters not working with WP(8)
//if (!isWebSql && !isWindows && isAndroid) pending('SKIP for Android plugin (cordova-android 6.x BUG: cordova/cordova-discuss#57)');
//if (!isWebSql && !isWindows && !isAndroid && !isWP8) pending('SKIP for iOS/macOS plugin (Cordova BUG: CB-9435)');

// NOTE: since the above test shows the UNICODE xxx (\u2013)
// is seen by the sqlite implementation OK, it is now concluded that
// the failure is caused by the native JSON result encoding.
var db = openDatabase("UNICODE-paragraph-separator-string-lowertext.db", "1.0", "Demo", DEFAULT_SIZE);

expect(db).toBeDefined();

db.transaction(function(tx) {
expect(tx).toBeDefined();

tx.executeSql("SELECT LOWER(?) AS lowertext", ['First\u2013Second'], function (tx_ignored, rs) {
expect(rs).toBeDefined();
expect(rs.rows.item(0).lowertext).toBe("first\u2013second");

// Close (plugin only) & finish:
(isWebSql) ? done() : db.close(done, done);
});
}, function(error) {
// NOT EXPECTED:
expect(false).toBe(true);
expect(error.message).toBe('--');
// Close (plugin only) & finish:
(isWebSql) ? done() : db.close(done, done);
});
}, MYTIMEOUT);

// NOTE: the next 3 tests show that for iOS/macOS/Android:
// XXX XXX

it(suiteName + "UNICODE \\u2019 xxx string length", function(done) {
if (isWP8) pending('BROKEN on WP(8)'); // [BUG #202] Certain UNICODE characters not working with WP(8)

// NOTE: this test verifies that the UNICODE xxx (\u2019)
// is seen by the sqlite implementation OK:
var db = openDatabase("UNICODE-line-separator-string-length.db", "1.0", "Demo", DEFAULT_SIZE);

expect(db).toBeDefined();

db.transaction(function(tx) {
expect(tx).toBeDefined();

tx.executeSql("select length(?) AS stringlength", ['First\u2019Second'], function (tx_ignored, rs) {
expect(rs).toBeDefined();
expect(rs.rows).toBeDefined();
expect(rs.rows.length).toBe(1);
expect(rs.rows.item(0).stringlength).toBe(12);

// Close (plugin only) & finish:
(isWebSql) ? done() : db.close(done, done);
});
}, function(error) {
// NOT EXPECTED:
expect(false).toBe(true);
expect(error.message).toBe('--');
// Close (plugin only) & finish:
(isWebSql) ? done() : db.close(done, done);
});
}, MYTIMEOUT);

it(suiteName + 'HEX value of string with UNICODE \\u2019 xxx', function(done) {
// NOTE: this test verifies that the UNICODE xxx (\u2019)
// is seen by the sqlite implementation OK:
var db = openDatabase("UNICODE-line-separator-hex-value-test.db", "1.0", "Demo", DEFAULT_SIZE);

expect(db).toBeDefined();

db.transaction(function(tx) {
expect(tx).toBeDefined();

tx.executeSql('SELECT HEX(?) AS myresult', ['1\u2019'], function (tx_ignored, rs) {
if (isWindows)
expect(rs.rows.item(0).myresult).toBe('31002820'); // (UTF-16le)
else
expect(rs.rows.item(0).myresult).toBe('31E28099'); // (UTF-8)

// Close (plugin only) & finish:
(isWebSql) ? done() : db.close(done, done);
});
}, function(error) {
// NOT EXPECTED:
expect(false).toBe(true);
expect(error.message).toBe('--');
// Close (plugin only) & finish:
(isWebSql) ? done() : db.close(done, done);
});
}, MYTIMEOUT);

it(suiteName + ' handles UNICODE \\u2019 xxx correctly [string test]', function (done) {
if (isWP8) pending('BROKEN on WP(8)'); // [BUG #202] UNICODE characters not working with WP(8)
//if (!isWebSql && !isWindows && isAndroid) pending('SKIP for Android plugin (cordova-android 6.x BUG: cordova/cordova-discuss#57)');
//if (!isWebSql && !isWindows && !isAndroid && !isWP8) pending('SKIP for iOS/macOS plugin (Cordova BUG: CB-9435)');
//if (isWebSql && !isWindows && isAndroid) pending('SKIP for Android Web SQL'); // TBD SKIP for Android Web for now

// NOTE: since the above test shows the UNICODE xxx (\u2019)
// is seen by the sqlite implementation OK, it is now concluded that
// the failure is caused by the native JSON result encoding.
var db = openDatabase("UNICODE-line-separator-string-lowertext.db", "1.0", "Demo", DEFAULT_SIZE);

expect(db).toBeDefined();

db.transaction(function(tx) {
expect(tx).toBeDefined();

tx.executeSql("SELECT LOWER(?) AS lowertext", ['First\u2019Second'], function (tx_ignored, rs) {
expect(rs).toBeDefined();
expect(rs.rows.item(0).lowertext).toBe("first\u2019second");

// Close (plugin only) & finish:
(isWebSql) ? done() : db.close(done, done);
});
}, function(error) {
// NOT EXPECTED:
expect(false).toBe(true);
expect(error.message).toBe('--');
// Close (plugin only) & finish:
(isWebSql) ? done() : db.close(done, done);
});
}, MYTIMEOUT);

// NOTE: the next 3 tests repeat the above for UNICODE \u2013 xxx
// on iOS/macOS/Android:
// XXX XXX

it(suiteName + "UNICODE \\u2029 paragraph separator string length", function(done) {
it(suiteName + "UNICODE \\u2013 xxx string length", function(done) {
if (isWP8) pending('BROKEN on WP(8)'); // [BUG #202] Certain UNICODE characters not working with WP(8)

// NOTE: this test verifies that the UNICODE paragraph separator (\u2029)
Expand Down
124 changes: 122 additions & 2 deletions spec/www/spec/db-tx-value-bindings-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1369,12 +1369,132 @@ var mytests = function() {
db.transaction(function (tx) {
tx.executeSql('DROP TABLE IF EXISTS test', [], function () {
tx.executeSql('CREATE TABLE test (name, id)', [], function() {
tx.executeSql('INSERT INTO test VALUES (?, "id1")', ['hello\u2028world'], function () {
tx.executeSql('INSERT INTO test VALUES (?, "id1")', ['hello\u2019world'], function () {
tx.executeSql('SELECT name FROM test', [], function (tx_ignored, rs) {
var name = rs.rows.item(0).name;

expect(name.length).toBe(11);
expect(name).toBe('hello\u2028world');
expect(name).toBe('hello\u2019world');

check1 = true;
});
});
});
});

}, function(error) {
// NOT EXPECTED:
expect(false).toBe(true);
expect(error.message).toBe('---');
// Close (plugin only) & finish:
(isWebSql) ? done() : db.close(done, done);

}, function() {
expect(check1).toBe(true);
// Close (plugin only) & finish:
(isWebSql) ? done() : db.close(done, done);
});
}, MYTIMEOUT);

it(suiteName +
' handles UNICODE \\u2013 xxx correctly in database', function (done) {
if (isWP8) pending('BROKEN on WP(8)'); // [BUG #202] UNICODE characters not working with WP(8)
//if (!isWebSql && !isWindows && isAndroid) pending('SKIP for Android plugin (cordova-android 6.x BUG: cordova/cordova-discuss#57)');
//if (!isWebSql && !isWindows && !isAndroid && !isWP8) pending('SKIP for iOS/macOS plugin (Cordova BUG: CB-9435)');

var db = openDatabase('UNICODE-line-separator-INSERT-test.db');

var check1 = false;

db.transaction(function (tx) {
tx.executeSql('DROP TABLE IF EXISTS test', [], function () {
tx.executeSql('CREATE TABLE test (name, id)', [], function() {
tx.executeSql('INSERT INTO test VALUES (?, "id1")', ['hello\u2013world'], function () {
tx.executeSql('SELECT name FROM test', [], function (tx_ignored, rs) {
var name = rs.rows.item(0).name;

expect(name.length).toBe(11);
expect(name).toBe('hello\u2013world');

check1 = true;
});
});
});
});

}, function(error) {
// NOT EXPECTED:
expect(false).toBe(true);
expect(error.message).toBe('---');
// Close (plugin only) & finish:
(isWebSql) ? done() : db.close(done, done);

}, function() {
expect(check1).toBe(true);
// Close (plugin only) & finish:
(isWebSql) ? done() : db.close(done, done);
});
}, MYTIMEOUT);

it(suiteName +
' handles UNICODE \\u2019 xxx correctly in database', function (done) {
if (isWP8) pending('BROKEN on WP(8)'); // [BUG #202] UNICODE characters not working with WP(8)
//if (!isWebSql && !isWindows && isAndroid) pending('SKIP for Android plugin (cordova-android 6.x BUG: cordova/cordova-discuss#57)');
//if (!isWebSql && !isWindows && !isAndroid && !isWP8) pending('SKIP for iOS/macOS plugin (Cordova BUG: CB-9435)');

var db = openDatabase('UNICODE-line-separator-INSERT-test.db');

var check1 = false;

db.transaction(function (tx) {
tx.executeSql('DROP TABLE IF EXISTS test', [], function () {
tx.executeSql('CREATE TABLE test (name, id)', [], function() {
tx.executeSql('INSERT INTO test VALUES (?, "id1")', ['hello\u2019world'], function () {
tx.executeSql('SELECT name FROM test', [], function (tx_ignored, rs) {
var name = rs.rows.item(0).name;

expect(name.length).toBe(11);
expect(name).toBe('hello\u2019world');

check1 = true;
});
});
});
});

}, function(error) {
// NOT EXPECTED:
expect(false).toBe(true);
expect(error.message).toBe('---');
// Close (plugin only) & finish:
(isWebSql) ? done() : db.close(done, done);

}, function() {
expect(check1).toBe(true);
// Close (plugin only) & finish:
(isWebSql) ? done() : db.close(done, done);
});
}, MYTIMEOUT);

it(suiteName +
' handles UNICODE \\u2013 xxx correctly in database', function (done) {
if (isWP8) pending('BROKEN on WP(8)'); // [BUG #202] UNICODE characters not working with WP(8)
//if (!isWebSql && !isWindows && isAndroid) pending('SKIP for Android plugin (cordova-android 6.x BUG: cordova/cordova-discuss#57)');
//if (!isWebSql && !isWindows && !isAndroid && !isWP8) pending('SKIP for iOS/macOS plugin (Cordova BUG: CB-9435)');

var db = openDatabase('UNICODE-line-separator-INSERT-test.db');

var check1 = false;

db.transaction(function (tx) {
tx.executeSql('DROP TABLE IF EXISTS test', [], function () {
tx.executeSql('CREATE TABLE test (name, id)', [], function() {
tx.executeSql('INSERT INTO test VALUES (?, "id1")', ['hello\u2013world'], function () {
tx.executeSql('SELECT name FROM test', [], function (tx_ignored, rs) {
var name = rs.rows.item(0).name;

expect(name.length).toBe(11);
expect(name).toBe('hello\u2013world');

check1 = true;
});
Expand Down

0 comments on commit cecd62b

Please sign in to comment.