11cb0ef41Sopenharmony_ci// Flags: --expose-internals 21cb0ef41Sopenharmony_ci'use strict'; 31cb0ef41Sopenharmony_ci 41cb0ef41Sopenharmony_cirequire('../common'); 51cb0ef41Sopenharmony_ciconst assert = require('assert'); 61cb0ef41Sopenharmony_ciconst util = require('internal/util'); 71cb0ef41Sopenharmony_ci 81cb0ef41Sopenharmony_ciconst tests = [ 91cb0ef41Sopenharmony_ci [undefined, 'utf8'], 101cb0ef41Sopenharmony_ci [null, 'utf8'], 111cb0ef41Sopenharmony_ci ['', 'utf8'], 121cb0ef41Sopenharmony_ci ['utf8', 'utf8'], 131cb0ef41Sopenharmony_ci ['utf-8', 'utf8'], 141cb0ef41Sopenharmony_ci ['UTF-8', 'utf8'], 151cb0ef41Sopenharmony_ci ['UTF8', 'utf8'], 161cb0ef41Sopenharmony_ci ['Utf8', 'utf8'], 171cb0ef41Sopenharmony_ci ['uTf-8', 'utf8'], 181cb0ef41Sopenharmony_ci ['utF-8', 'utf8'], 191cb0ef41Sopenharmony_ci ['ucs2', 'utf16le'], 201cb0ef41Sopenharmony_ci ['UCS2', 'utf16le'], 211cb0ef41Sopenharmony_ci ['UcS2', 'utf16le'], 221cb0ef41Sopenharmony_ci ['ucs-2', 'utf16le'], 231cb0ef41Sopenharmony_ci ['UCS-2', 'utf16le'], 241cb0ef41Sopenharmony_ci ['UcS-2', 'utf16le'], 251cb0ef41Sopenharmony_ci ['utf16le', 'utf16le'], 261cb0ef41Sopenharmony_ci ['utf-16le', 'utf16le'], 271cb0ef41Sopenharmony_ci ['UTF-16LE', 'utf16le'], 281cb0ef41Sopenharmony_ci ['UTF16LE', 'utf16le'], 291cb0ef41Sopenharmony_ci ['binary', 'latin1'], 301cb0ef41Sopenharmony_ci ['BINARY', 'latin1'], 311cb0ef41Sopenharmony_ci ['latin1', 'latin1'], 321cb0ef41Sopenharmony_ci ['LaTiN1', 'latin1'], 331cb0ef41Sopenharmony_ci ['base64', 'base64'], 341cb0ef41Sopenharmony_ci ['BASE64', 'base64'], 351cb0ef41Sopenharmony_ci ['Base64', 'base64'], 361cb0ef41Sopenharmony_ci ['base64url', 'base64url'], 371cb0ef41Sopenharmony_ci ['BASE64url', 'base64url'], 381cb0ef41Sopenharmony_ci ['Base64url', 'base64url'], 391cb0ef41Sopenharmony_ci ['hex', 'hex'], 401cb0ef41Sopenharmony_ci ['HEX', 'hex'], 411cb0ef41Sopenharmony_ci ['ASCII', 'ascii'], 421cb0ef41Sopenharmony_ci ['AsCii', 'ascii'], 431cb0ef41Sopenharmony_ci ['foo', undefined], 441cb0ef41Sopenharmony_ci [1, undefined], 451cb0ef41Sopenharmony_ci [false, undefined], 461cb0ef41Sopenharmony_ci [NaN, undefined], 471cb0ef41Sopenharmony_ci [0, undefined], 481cb0ef41Sopenharmony_ci [[], undefined], 491cb0ef41Sopenharmony_ci [{}, undefined], 501cb0ef41Sopenharmony_ci]; 511cb0ef41Sopenharmony_ci 521cb0ef41Sopenharmony_citests.forEach((e, i) => { 531cb0ef41Sopenharmony_ci const res = util.normalizeEncoding(e[0]); 541cb0ef41Sopenharmony_ci assert.strictEqual(res, e[1], `#${i} failed: expected ${e[1]}, got ${res}`); 551cb0ef41Sopenharmony_ci}); 56