Move string escaping tests to proper locations.
This commit is contained in:
parent
ffe51c20f2
commit
539d3bae54
153
test/integration/client/escape-tests.js
Normal file
153
test/integration/client/escape-tests.js
Normal file
@ -0,0 +1,153 @@
|
||||
var helper = require(__dirname + '/test-helper');
|
||||
|
||||
function createClient(callback) {
|
||||
var client = new Client(helper.config);
|
||||
client.connect(function(err) {
|
||||
return callback(client);
|
||||
});
|
||||
}
|
||||
|
||||
test('escapeLiteral: no special characters', function() {
|
||||
createClient(function(client) {
|
||||
var expected = "'hello world'";
|
||||
var actual = client.escapeLiteral('hello world');
|
||||
assert.equal(expected, actual);
|
||||
client.end();
|
||||
});
|
||||
});
|
||||
|
||||
test('escapeLiteral: contains double quotes only', function() {
|
||||
createClient(function(client) {
|
||||
var expected = "'hello \" world'";
|
||||
var actual = client.escapeLiteral('hello " world');
|
||||
assert.equal(expected, actual);
|
||||
client.end();
|
||||
});
|
||||
});
|
||||
|
||||
test('escapeLiteral: contains single quotes only', function() {
|
||||
createClient(function(client) {
|
||||
var expected = "'hello \'\' world'";
|
||||
var actual = client.escapeLiteral('hello \' world');
|
||||
assert.equal(expected, actual);
|
||||
client.end();
|
||||
});
|
||||
});
|
||||
|
||||
test('escapeLiteral: contains backslashes only', function() {
|
||||
createClient(function(client) {
|
||||
var expected = " E'hello \\\\ world'";
|
||||
var actual = client.escapeLiteral('hello \\ world');
|
||||
assert.equal(expected, actual);
|
||||
client.end();
|
||||
});
|
||||
});
|
||||
|
||||
test('escapeLiteral: contains single quotes and double quotes', function() {
|
||||
createClient(function(client) {
|
||||
var expected = "'hello '' \" world'";
|
||||
var actual = client.escapeLiteral('hello \' " world');
|
||||
assert.equal(expected, actual);
|
||||
client.end();
|
||||
});
|
||||
});
|
||||
|
||||
test('escapeLiteral: contains double quotes and backslashes', function() {
|
||||
createClient(function(client) {
|
||||
var expected = " E'hello \\\\ \" world'";
|
||||
var actual = client.escapeLiteral('hello \\ " world');
|
||||
assert.equal(expected, actual);
|
||||
client.end();
|
||||
});
|
||||
});
|
||||
|
||||
test('escapeLiteral: contains single quotes and backslashes', function() {
|
||||
createClient(function(client) {
|
||||
var expected = " E'hello \\\\ '' world'";
|
||||
var actual = client.escapeLiteral('hello \\ \' world');
|
||||
assert.equal(expected, actual);
|
||||
client.end();
|
||||
});
|
||||
});
|
||||
|
||||
test('escapeLiteral: contains single quotes, double quotes, and backslashes', function() {
|
||||
createClient(function(client) {
|
||||
var expected = " E'hello \\\\ '' \" world'";
|
||||
var actual = client.escapeLiteral('hello \\ \' " world');
|
||||
assert.equal(expected, actual);
|
||||
client.end();
|
||||
});
|
||||
});
|
||||
|
||||
test('escapeIdentifier: no special characters', function() {
|
||||
createClient(function(client) {
|
||||
var expected = '"hello world"';
|
||||
var actual = client.escapeIdentifier('hello world');
|
||||
assert.equal(expected, actual);
|
||||
client.end();
|
||||
});
|
||||
});
|
||||
|
||||
test('escapeIdentifier: contains double quotes only', function() {
|
||||
createClient(function(client) {
|
||||
var expected = '"hello "" world"';
|
||||
var actual = client.escapeIdentifier('hello " world');
|
||||
assert.equal(expected, actual);
|
||||
client.end();
|
||||
});
|
||||
});
|
||||
|
||||
test('escapeIdentifier: contains single quotes only', function() {
|
||||
createClient(function(client) {
|
||||
var expected = '"hello \' world"';
|
||||
var actual = client.escapeIdentifier('hello \' world');
|
||||
assert.equal(expected, actual);
|
||||
client.end();
|
||||
});
|
||||
});
|
||||
|
||||
test('escapeIdentifier: contains backslashes only', function() {
|
||||
createClient(function(client) {
|
||||
var expected = '"hello \\ world"';
|
||||
var actual = client.escapeIdentifier('hello \\ world');
|
||||
assert.equal(expected, actual);
|
||||
client.end();
|
||||
});
|
||||
});
|
||||
|
||||
test('escapeIdentifier: contains single quotes and double quotes', function() {
|
||||
createClient(function(client) {
|
||||
var expected = '"hello \' "" world"';
|
||||
var actual = client.escapeIdentifier('hello \' " world');
|
||||
assert.equal(expected, actual);
|
||||
client.end();
|
||||
});
|
||||
});
|
||||
|
||||
test('escapeIdentifier: contains double quotes and backslashes', function() {
|
||||
return createClient(function(client) {
|
||||
var expected = '"hello \\ "" world"';
|
||||
var actual = client.escapeIdentifier('hello \\ " world');
|
||||
assert.equal(expected, actual);
|
||||
client.end();
|
||||
return;
|
||||
});
|
||||
});
|
||||
|
||||
test('escapeIdentifier: contains single quotes and backslashes', function() {
|
||||
createClient(function(client) {
|
||||
var expected = '"hello \\ \' world"';
|
||||
var actual = client.escapeIdentifier('hello \\ \' world');
|
||||
assert.equal(expected, actual);
|
||||
client.end();
|
||||
});
|
||||
});
|
||||
|
||||
test('escapeIdentifier: contains single quotes, double quotes, and backslashes', function() {
|
||||
createClient(function(client) {
|
||||
var expected = '"hello \\ \' "" world"';
|
||||
var actual = client.escapeIdentifier('hello \\ \' " world');
|
||||
assert.equal(expected, actual);
|
||||
client.end();
|
||||
});
|
||||
});
|
@ -1,120 +0,0 @@
|
||||
var helper = require(__dirname + "/../test-helper");
|
||||
var Client = require(__dirname + "/../../lib/native");
|
||||
|
||||
function createClient() {
|
||||
var client = new Client(helper.config);
|
||||
client.connect();
|
||||
return client;
|
||||
}
|
||||
|
||||
test('escapeLiteral: no special characters', function() {
|
||||
var client = createClient();
|
||||
var expected = "'hello world'";
|
||||
var actual = client.escapeLiteral('hello world');
|
||||
assert.equal(expected, actual);
|
||||
});
|
||||
|
||||
test('escapeLiteral: contains double quotes only', function() {
|
||||
var client = createClient();
|
||||
var expected = "'hello \" world'";
|
||||
var actual = client.escapeLiteral('hello " world');
|
||||
assert.equal(expected, actual);
|
||||
});
|
||||
|
||||
test('escapeLiteral: contains single quotes only', function() {
|
||||
var client = createClient();
|
||||
var expected = "'hello \'\' world'";
|
||||
var actual = client.escapeLiteral('hello \' world');
|
||||
assert.equal(expected, actual);
|
||||
});
|
||||
|
||||
test('escapeLiteral: contains backslashes only', function() {
|
||||
var client = createClient();
|
||||
var expected = " E'hello \\\\ world'";
|
||||
var actual = client.escapeLiteral('hello \\ world');
|
||||
assert.equal(expected, actual);
|
||||
});
|
||||
|
||||
test('escapeLiteral: contains single quotes and double quotes', function() {
|
||||
var client = createClient();
|
||||
var expected = "'hello '' \" world'";
|
||||
var actual = client.escapeLiteral('hello \' " world');
|
||||
assert.equal(expected, actual);
|
||||
});
|
||||
|
||||
test('escapeLiteral: contains double quotes and backslashes', function() {
|
||||
var client = createClient();
|
||||
var expected = " E'hello \\\\ \" world'";
|
||||
var actual = client.escapeLiteral('hello \\ " world');
|
||||
assert.equal(expected, actual);
|
||||
});
|
||||
|
||||
test('escapeLiteral: contains single quotes and backslashes', function() {
|
||||
var client = createClient();
|
||||
var expected = " E'hello \\\\ '' world'";
|
||||
var actual = client.escapeLiteral('hello \\ \' world');
|
||||
assert.equal(expected, actual);
|
||||
});
|
||||
|
||||
test('escapeLiteral: contains single quotes, double quotes, and backslashes', function() {
|
||||
var client = createClient();
|
||||
var expected = " E'hello \\\\ '' \" world'";
|
||||
var actual = client.escapeLiteral('hello \\ \' " world');
|
||||
assert.equal(expected, actual);
|
||||
});
|
||||
|
||||
test('escapeIdentifier: no special characters', function() {
|
||||
var client = createClient();
|
||||
var expected = '"hello world"';
|
||||
var actual = client.escapeIdentifier('hello world');
|
||||
assert.equal(expected, actual);
|
||||
});
|
||||
|
||||
test('escapeIdentifier: contains double quotes only', function() {
|
||||
var client = createClient();
|
||||
var expected = '"hello "" world"';
|
||||
var actual = client.escapeIdentifier('hello " world');
|
||||
assert.equal(expected, actual);
|
||||
});
|
||||
|
||||
test('escapeIdentifier: contains single quotes only', function() {
|
||||
var client = createClient();
|
||||
var expected = '"hello \' world"';
|
||||
var actual = client.escapeIdentifier('hello \' world');
|
||||
assert.equal(expected, actual);
|
||||
});
|
||||
|
||||
test('escapeIdentifier: contains backslashes only', function() {
|
||||
var client = createClient();
|
||||
var expected = '"hello \\ world"';
|
||||
var actual = client.escapeIdentifier('hello \\ world');
|
||||
assert.equal(expected, actual);
|
||||
});
|
||||
|
||||
test('escapeIdentifier: contains single quotes and double quotes', function() {
|
||||
var client = createClient();
|
||||
var expected = '"hello \' "" world"';
|
||||
var actual = client.escapeIdentifier('hello \' " world');
|
||||
assert.equal(expected, actual);
|
||||
});
|
||||
|
||||
test('escapeIdentifier: contains double quotes and backslashes', function() {
|
||||
var client = createClient();
|
||||
var expected = '"hello \\ "" world"';
|
||||
var actual = client.escapeIdentifier('hello \\ " world');
|
||||
assert.equal(expected, actual);
|
||||
});
|
||||
|
||||
test('escapeIdentifier: contains single quotes and backslashes', function() {
|
||||
var client = createClient();
|
||||
var expected = '"hello \\ \' world"';
|
||||
var actual = client.escapeIdentifier('hello \\ \' world');
|
||||
assert.equal(expected, actual);
|
||||
});
|
||||
|
||||
test('escapeIdentifier: contains single quotes, double quotes, and backslashes', function() {
|
||||
var client = createClient();
|
||||
var expected = '"hello \\ \' "" world"';
|
||||
var actual = client.escapeIdentifier('hello \\ \' " world');
|
||||
assert.equal(expected, actual);
|
||||
});
|
153
test/unit/client/escape-tests.js
Normal file
153
test/unit/client/escape-tests.js
Normal file
@ -0,0 +1,153 @@
|
||||
var helper = require(__dirname + '/test-helper');
|
||||
|
||||
function createClient(callback) {
|
||||
var client = new Client(helper.config);
|
||||
client.connect(function(err) {
|
||||
return callback(client);
|
||||
});
|
||||
}
|
||||
|
||||
test('escapeLiteral: no special characters', function() {
|
||||
createClient(function(client) {
|
||||
var expected = "'hello world'";
|
||||
var actual = client.escapeLiteral('hello world');
|
||||
assert.equal(expected, actual);
|
||||
client.end();
|
||||
});
|
||||
});
|
||||
|
||||
test('escapeLiteral: contains double quotes only', function() {
|
||||
createClient(function(client) {
|
||||
var expected = "'hello \" world'";
|
||||
var actual = client.escapeLiteral('hello " world');
|
||||
assert.equal(expected, actual);
|
||||
client.end();
|
||||
});
|
||||
});
|
||||
|
||||
test('escapeLiteral: contains single quotes only', function() {
|
||||
createClient(function(client) {
|
||||
var expected = "'hello \'\' world'";
|
||||
var actual = client.escapeLiteral('hello \' world');
|
||||
assert.equal(expected, actual);
|
||||
client.end();
|
||||
});
|
||||
});
|
||||
|
||||
test('escapeLiteral: contains backslashes only', function() {
|
||||
createClient(function(client) {
|
||||
var expected = " E'hello \\\\ world'";
|
||||
var actual = client.escapeLiteral('hello \\ world');
|
||||
assert.equal(expected, actual);
|
||||
client.end();
|
||||
});
|
||||
});
|
||||
|
||||
test('escapeLiteral: contains single quotes and double quotes', function() {
|
||||
createClient(function(client) {
|
||||
var expected = "'hello '' \" world'";
|
||||
var actual = client.escapeLiteral('hello \' " world');
|
||||
assert.equal(expected, actual);
|
||||
client.end();
|
||||
});
|
||||
});
|
||||
|
||||
test('escapeLiteral: contains double quotes and backslashes', function() {
|
||||
createClient(function(client) {
|
||||
var expected = " E'hello \\\\ \" world'";
|
||||
var actual = client.escapeLiteral('hello \\ " world');
|
||||
assert.equal(expected, actual);
|
||||
client.end();
|
||||
});
|
||||
});
|
||||
|
||||
test('escapeLiteral: contains single quotes and backslashes', function() {
|
||||
createClient(function(client) {
|
||||
var expected = " E'hello \\\\ '' world'";
|
||||
var actual = client.escapeLiteral('hello \\ \' world');
|
||||
assert.equal(expected, actual);
|
||||
client.end();
|
||||
});
|
||||
});
|
||||
|
||||
test('escapeLiteral: contains single quotes, double quotes, and backslashes', function() {
|
||||
createClient(function(client) {
|
||||
var expected = " E'hello \\\\ '' \" world'";
|
||||
var actual = client.escapeLiteral('hello \\ \' " world');
|
||||
assert.equal(expected, actual);
|
||||
client.end();
|
||||
});
|
||||
});
|
||||
|
||||
test('escapeIdentifier: no special characters', function() {
|
||||
createClient(function(client) {
|
||||
var expected = '"hello world"';
|
||||
var actual = client.escapeIdentifier('hello world');
|
||||
assert.equal(expected, actual);
|
||||
client.end();
|
||||
});
|
||||
});
|
||||
|
||||
test('escapeIdentifier: contains double quotes only', function() {
|
||||
createClient(function(client) {
|
||||
var expected = '"hello "" world"';
|
||||
var actual = client.escapeIdentifier('hello " world');
|
||||
assert.equal(expected, actual);
|
||||
client.end();
|
||||
});
|
||||
});
|
||||
|
||||
test('escapeIdentifier: contains single quotes only', function() {
|
||||
createClient(function(client) {
|
||||
var expected = '"hello \' world"';
|
||||
var actual = client.escapeIdentifier('hello \' world');
|
||||
assert.equal(expected, actual);
|
||||
client.end();
|
||||
});
|
||||
});
|
||||
|
||||
test('escapeIdentifier: contains backslashes only', function() {
|
||||
createClient(function(client) {
|
||||
var expected = '"hello \\ world"';
|
||||
var actual = client.escapeIdentifier('hello \\ world');
|
||||
assert.equal(expected, actual);
|
||||
client.end();
|
||||
});
|
||||
});
|
||||
|
||||
test('escapeIdentifier: contains single quotes and double quotes', function() {
|
||||
createClient(function(client) {
|
||||
var expected = '"hello \' "" world"';
|
||||
var actual = client.escapeIdentifier('hello \' " world');
|
||||
assert.equal(expected, actual);
|
||||
client.end();
|
||||
});
|
||||
});
|
||||
|
||||
test('escapeIdentifier: contains double quotes and backslashes', function() {
|
||||
return createClient(function(client) {
|
||||
var expected = '"hello \\ "" world"';
|
||||
var actual = client.escapeIdentifier('hello \\ " world');
|
||||
assert.equal(expected, actual);
|
||||
client.end();
|
||||
return;
|
||||
});
|
||||
});
|
||||
|
||||
test('escapeIdentifier: contains single quotes and backslashes', function() {
|
||||
createClient(function(client) {
|
||||
var expected = '"hello \\ \' world"';
|
||||
var actual = client.escapeIdentifier('hello \\ \' world');
|
||||
assert.equal(expected, actual);
|
||||
client.end();
|
||||
});
|
||||
});
|
||||
|
||||
test('escapeIdentifier: contains single quotes, double quotes, and backslashes', function() {
|
||||
createClient(function(client) {
|
||||
var expected = '"hello \\ \' "" world"';
|
||||
var actual = client.escapeIdentifier('hello \\ \' " world');
|
||||
assert.equal(expected, actual);
|
||||
client.end();
|
||||
});
|
||||
});
|
@ -1,113 +0,0 @@
|
||||
require(__dirname + "/test-helper");
|
||||
|
||||
test('escapeLiteral: no special characters', function() {
|
||||
var client = createClient();
|
||||
var expected = "'hello world'";
|
||||
var actual = client.escapeLiteral('hello world');
|
||||
assert.equal(expected, actual);
|
||||
});
|
||||
|
||||
test('escapeLiteral: contains double quotes only', function() {
|
||||
var client = createClient();
|
||||
var expected = "'hello \" world'";
|
||||
var actual = client.escapeLiteral('hello " world');
|
||||
assert.equal(expected, actual);
|
||||
});
|
||||
|
||||
test('escapeLiteral: contains single quotes only', function() {
|
||||
var client = createClient();
|
||||
var expected = "'hello \'\' world'";
|
||||
var actual = client.escapeLiteral('hello \' world');
|
||||
assert.equal(expected, actual);
|
||||
});
|
||||
|
||||
test('escapeLiteral: contains backslashes only', function() {
|
||||
var client = createClient();
|
||||
var expected = " E'hello \\\\ world'";
|
||||
var actual = client.escapeLiteral('hello \\ world');
|
||||
assert.equal(expected, actual);
|
||||
});
|
||||
|
||||
test('escapeLiteral: contains single quotes and double quotes', function() {
|
||||
var client = createClient();
|
||||
var expected = "'hello '' \" world'";
|
||||
var actual = client.escapeLiteral('hello \' " world');
|
||||
assert.equal(expected, actual);
|
||||
});
|
||||
|
||||
test('escapeLiteral: contains double quotes and backslashes', function() {
|
||||
var client = createClient();
|
||||
var expected = " E'hello \\\\ \" world'";
|
||||
var actual = client.escapeLiteral('hello \\ " world');
|
||||
assert.equal(expected, actual);
|
||||
});
|
||||
|
||||
test('escapeLiteral: contains single quotes and backslashes', function() {
|
||||
var client = createClient();
|
||||
var expected = " E'hello \\\\ '' world'";
|
||||
var actual = client.escapeLiteral('hello \\ \' world');
|
||||
assert.equal(expected, actual);
|
||||
});
|
||||
|
||||
test('escapeLiteral: contains single quotes, double quotes, and backslashes', function() {
|
||||
var client = createClient();
|
||||
var expected = " E'hello \\\\ '' \" world'";
|
||||
var actual = client.escapeLiteral('hello \\ \' " world');
|
||||
assert.equal(expected, actual);
|
||||
});
|
||||
|
||||
test('escapeIdentifier: no special characters', function() {
|
||||
var client = createClient();
|
||||
var expected = '"hello world"';
|
||||
var actual = client.escapeIdentifier('hello world');
|
||||
assert.equal(expected, actual);
|
||||
});
|
||||
|
||||
test('escapeIdentifier: contains double quotes only', function() {
|
||||
var client = createClient();
|
||||
var expected = '"hello "" world"';
|
||||
var actual = client.escapeIdentifier('hello " world');
|
||||
assert.equal(expected, actual);
|
||||
});
|
||||
|
||||
test('escapeIdentifier: contains single quotes only', function() {
|
||||
var client = createClient();
|
||||
var expected = '"hello \' world"';
|
||||
var actual = client.escapeIdentifier('hello \' world');
|
||||
assert.equal(expected, actual);
|
||||
});
|
||||
|
||||
test('escapeIdentifier: contains backslashes only', function() {
|
||||
var client = createClient();
|
||||
var expected = '"hello \\ world"';
|
||||
var actual = client.escapeIdentifier('hello \\ world');
|
||||
assert.equal(expected, actual);
|
||||
});
|
||||
|
||||
test('escapeIdentifier: contains single quotes and double quotes', function() {
|
||||
var client = createClient();
|
||||
var expected = '"hello \' "" world"';
|
||||
var actual = client.escapeIdentifier('hello \' " world');
|
||||
assert.equal(expected, actual);
|
||||
});
|
||||
|
||||
test('escapeIdentifier: contains double quotes and backslashes', function() {
|
||||
var client = createClient();
|
||||
var expected = '"hello \\ "" world"';
|
||||
var actual = client.escapeIdentifier('hello \\ " world');
|
||||
assert.equal(expected, actual);
|
||||
});
|
||||
|
||||
test('escapeIdentifier: contains single quotes and backslashes', function() {
|
||||
var client = createClient();
|
||||
var expected = '"hello \\ \' world"';
|
||||
var actual = client.escapeIdentifier('hello \\ \' world');
|
||||
assert.equal(expected, actual);
|
||||
});
|
||||
|
||||
test('escapeIdentifier: contains single quotes, double quotes, and backslashes', function() {
|
||||
var client = createClient();
|
||||
var expected = '"hello \\ \' "" world"';
|
||||
var actual = client.escapeIdentifier('hello \\ \' " world');
|
||||
assert.equal(expected, actual);
|
||||
});
|
Loading…
Reference in New Issue
Block a user