This repository has been archived by the owner on Jul 10, 2019. It is now read-only.
forked from andris9/encoding
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtest.js
35 lines (34 loc) · 1.5 KB
/
test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
var testCase = require('nodeunit').testCase,
encoding = require("./index");
exports["General tests"] = {
"From UTF-8 to Latin_1": function(test){
var input = "ÕÄÖÜ",
expected = new Buffer([0xd5, 0xc4, 0xd6, 0xdc]);
test.deepEqual(encoding.convert(input, "latin1"), expected);
test.done();
},
"From Latin_1 to UTF-8": function(test){
var input = new Buffer([0xd5, 0xc4, 0xd6, 0xdc]),
expected = "ÕÄÖÜ";
test.deepEqual(encoding.convert(input, "utf-8", "latin1").toString(), expected);
test.done();
},
"From Latin_13 to Latin_15": function(test){
var input = new Buffer([0xd5, 0xc4, 0xd6, 0xdc, 0xd0]),
expected = new Buffer([0xd5, 0xc4, 0xd6, 0xdc, 0xA6]);
test.deepEqual(encoding.convert(input, "latin_15", "latin13"), expected);
test.done();
},
"From Latin_13 to Latin_15 lite": function(test){
var input = new Buffer([0xd5, 0xc4, 0xd6, 0xdc, 0xd0]),
expected = new Buffer([0xd5, 0xc4, 0xd6, 0xdc, 0xA6]);
test.deepEqual(encoding.convert(input, "latin_15", "latin13", true), expected);
test.done();
},
"From ISO-2022-JP to UTF-8": function(test){
var input = new Buffer("GyRCM1g5OzU7PVEwdzgmPSQ4IUYkMnFKczlwGyhC", "base64"),
expected = new Buffer("5a2m5qCh5oqA6KGT5ZOh56CU5L+u5qSc6KiO5Lya5aCx5ZGK", "base64");
test.deepEqual(encoding.convert(input, "utf-8", "ISO-2022-JP"), expected);
test.done();
}
}