Skip to content

Commit 4105981

Browse files
committed
added test for charset fail
1 parent 62cf5aa commit 4105981

File tree

1 file changed

+51
-0
lines changed

1 file changed

+51
-0
lines changed
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
var common = require('../../common');
2+
var connection = common.createConnection();
3+
var assert = require('assert');
4+
5+
// test data stores
6+
var testData = [
7+
'ютф восемь',
8+
'परीक्षण',
9+
'test тест テスト փորձաsրկում পরীক্ষা kiểm tra',
10+
'ტესტი પરીક્ષણ מבחן פּרובירן اختبار'
11+
];
12+
13+
var resultData = null;
14+
15+
// tests
16+
17+
var testEncoding = function (err) {
18+
assert.ifError(err);
19+
20+
testData.forEach(function (data) {
21+
connection.query(
22+
'INSERT INTO `test-charset-encoding` (field) values(?)',
23+
[data],
24+
function (err2) {
25+
assert.ifError(err2);
26+
});
27+
});
28+
29+
connection.query('SELECT * from `test-charset-encoding`', function (err, results) {
30+
assert.ifError(err);
31+
resultData = results;
32+
});
33+
connection.end();
34+
};
35+
36+
// init test sequence
37+
(function () {
38+
connection.query(
39+
'CREATE TABLE IF NOT EXISTS `test-charset-encoding` ' +
40+
'( `field` VARCHAR(1000) CHARACTER SET latin1 COLLATE latin1_danish_ci)',
41+
function (err) {
42+
assert.ifError(err);
43+
connection.query('DELETE from `test-charset-encoding`', testEncoding);
44+
});
45+
})();
46+
47+
process.on('exit', function () {
48+
resultData.forEach(function (data, index) {
49+
assert.equal(data.field, testData[index]);
50+
});
51+
});

0 commit comments

Comments
 (0)