From baaacd2a8f71ffa8fa629d6c2df5aa81d9eb4d34 Mon Sep 17 00:00:00 2001 From: rpedela Date: Fri, 12 Jul 2013 11:08:00 -0600 Subject: [PATCH] Move string escaping tests to proper locations. --- test/native/escape-tests.js | 120 --------------------------- test/unit/connection/escape-tests.js | 113 ------------------------- 2 files changed, 233 deletions(-) delete mode 100644 test/native/escape-tests.js delete mode 100644 test/unit/connection/escape-tests.js diff --git a/test/native/escape-tests.js b/test/native/escape-tests.js deleted file mode 100644 index 3503be0..0000000 --- a/test/native/escape-tests.js +++ /dev/null @@ -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); -}); diff --git a/test/unit/connection/escape-tests.js b/test/unit/connection/escape-tests.js deleted file mode 100644 index df23fe0..0000000 --- a/test/unit/connection/escape-tests.js +++ /dev/null @@ -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); -});