11cb0ef41Sopenharmony_ci'use strict'; 21cb0ef41Sopenharmony_ci 31cb0ef41Sopenharmony_civar encoding = require('../lib/encoding'); 41cb0ef41Sopenharmony_ci 51cb0ef41Sopenharmony_ciexports['General tests'] = { 61cb0ef41Sopenharmony_ci 'From UTF-8 to Latin_1': function (test) { 71cb0ef41Sopenharmony_ci var input = 'ÕÄÖÜ', 81cb0ef41Sopenharmony_ci expected = Buffer.from([0xd5, 0xc4, 0xd6, 0xdc]); 91cb0ef41Sopenharmony_ci test.deepEqual(encoding.convert(input, 'latin1'), expected); 101cb0ef41Sopenharmony_ci test.done(); 111cb0ef41Sopenharmony_ci }, 121cb0ef41Sopenharmony_ci 131cb0ef41Sopenharmony_ci 'From Latin_1 to UTF-8': function (test) { 141cb0ef41Sopenharmony_ci var input = Buffer.from([0xd5, 0xc4, 0xd6, 0xdc]), 151cb0ef41Sopenharmony_ci expected = 'ÕÄÖÜ'; 161cb0ef41Sopenharmony_ci test.deepEqual(encoding.convert(input, 'utf-8', 'latin1').toString(), expected); 171cb0ef41Sopenharmony_ci test.done(); 181cb0ef41Sopenharmony_ci }, 191cb0ef41Sopenharmony_ci 201cb0ef41Sopenharmony_ci 'From UTF-8 to UTF-8': function (test) { 211cb0ef41Sopenharmony_ci var input = 'ÕÄÖÜ', 221cb0ef41Sopenharmony_ci expected = Buffer.from('ÕÄÖÜ'); 231cb0ef41Sopenharmony_ci test.deepEqual(encoding.convert(input, 'utf-8', 'utf-8'), expected); 241cb0ef41Sopenharmony_ci test.done(); 251cb0ef41Sopenharmony_ci }, 261cb0ef41Sopenharmony_ci 271cb0ef41Sopenharmony_ci 'From Latin_13 to Latin_15': function (test) { 281cb0ef41Sopenharmony_ci var input = Buffer.from([0xd5, 0xc4, 0xd6, 0xdc, 0xd0]), 291cb0ef41Sopenharmony_ci expected = Buffer.from([0xd5, 0xc4, 0xd6, 0xdc, 0xa6]); 301cb0ef41Sopenharmony_ci test.deepEqual(encoding.convert(input, 'latin_15', 'latin13'), expected); 311cb0ef41Sopenharmony_ci test.done(); 321cb0ef41Sopenharmony_ci } 331cb0ef41Sopenharmony_ci 341cb0ef41Sopenharmony_ci /* 351cb0ef41Sopenharmony_ci // ISO-2022-JP is not supported by iconv-lite 361cb0ef41Sopenharmony_ci "From ISO-2022-JP to UTF-8 with Iconv": function (test) { 371cb0ef41Sopenharmony_ci var input = Buffer.from( 381cb0ef41Sopenharmony_ci "GyRCM1g5OzU7PVEwdzgmPSQ4IUYkMnFKczlwGyhC", 391cb0ef41Sopenharmony_ci "base64" 401cb0ef41Sopenharmony_ci ), 411cb0ef41Sopenharmony_ci expected = Buffer.from( 421cb0ef41Sopenharmony_ci "5a2m5qCh5oqA6KGT5ZOh56CU5L+u5qSc6KiO5Lya5aCx5ZGK", 431cb0ef41Sopenharmony_ci "base64" 441cb0ef41Sopenharmony_ci ); 451cb0ef41Sopenharmony_ci test.deepEqual(encoding.convert(input, "utf-8", "ISO-2022-JP"), expected); 461cb0ef41Sopenharmony_ci test.done(); 471cb0ef41Sopenharmony_ci }, 481cb0ef41Sopenharmony_ci */ 491cb0ef41Sopenharmony_ci}; 50