11cb0ef41Sopenharmony_ci'use strict'; 21cb0ef41Sopenharmony_ci// Test compressing and uncompressing a string with brotli 31cb0ef41Sopenharmony_ci 41cb0ef41Sopenharmony_ciconst common = require('../common'); 51cb0ef41Sopenharmony_ciconst assert = require('assert'); 61cb0ef41Sopenharmony_ciconst zlib = require('zlib'); 71cb0ef41Sopenharmony_ci 81cb0ef41Sopenharmony_ciconst inputString = 'ΩΩLorem ipsum dolor sit amet, consectetur adipiscing eli' + 91cb0ef41Sopenharmony_ci 't. Morbi faucibus, purus at gravida dictum, libero arcu ' + 101cb0ef41Sopenharmony_ci 'convallis lacus, in commodo libero metus eu nisi. Nullam' + 111cb0ef41Sopenharmony_ci ' commodo, neque nec porta placerat, nisi est fermentum a' + 121cb0ef41Sopenharmony_ci 'ugue, vitae gravida tellus sapien sit amet tellus. Aenea' + 131cb0ef41Sopenharmony_ci 'n non diam orci. Proin quis elit turpis. Suspendisse non' + 141cb0ef41Sopenharmony_ci ' diam ipsum. Suspendisse nec ullamcorper odio. Vestibulu' + 151cb0ef41Sopenharmony_ci 'm arcu mi, sodales non suscipit id, ultrices ut massa. S' + 161cb0ef41Sopenharmony_ci 'ed ac sem sit amet arcu malesuada fermentum. Nunc sed. '; 171cb0ef41Sopenharmony_ciconst compressedString = 'G/gBQBwHdky2aHV5KK9Snf05//1pPdmNw/7232fnIm1IB' + 181cb0ef41Sopenharmony_ci 'K1AA8RsN8OB8Nb7Lpgk3UWWUlzQXZyHQeBBbXMTQXC1j7' + 191cb0ef41Sopenharmony_ci 'wg3LJs9LqOGHRH2bj/a2iCTLLx8hBOyTqgoVuD1e+Qqdn' + 201cb0ef41Sopenharmony_ci 'f1rkUNyrWq6LtOhWgxP3QUwdhKGdZm3rJWaDDBV7+pDk1' + 211cb0ef41Sopenharmony_ci 'MIkrmjp4ma2xVi5MsgJScA3tP1I7mXeby6MELozrwoBQD' + 221cb0ef41Sopenharmony_ci 'mVTnEAicZNj4lkGqntJe2qSnGyeMmcFgraK94vCg/4iLu' + 231cb0ef41Sopenharmony_ci 'Tw5RhKhnVY++dZ6niUBmRqIutsjf5TzwF5iAg8a9UkjF5' + 241cb0ef41Sopenharmony_ci '2eZ0tB2vo6v8SqVfNMkBmmhxr0NT9LkYF69aEjlYzj7IE' + 251cb0ef41Sopenharmony_ci 'KmEUQf1HBogRYhFIt4ymRNEgHAIzOyNEsQM='; 261cb0ef41Sopenharmony_ci 271cb0ef41Sopenharmony_cizlib.brotliCompress(inputString, common.mustCall((err, buffer) => { 281cb0ef41Sopenharmony_ci assert(inputString.length > buffer.length); 291cb0ef41Sopenharmony_ci 301cb0ef41Sopenharmony_ci zlib.brotliDecompress(buffer, common.mustCall((err, buffer) => { 311cb0ef41Sopenharmony_ci assert.strictEqual(buffer.toString(), inputString); 321cb0ef41Sopenharmony_ci })); 331cb0ef41Sopenharmony_ci})); 341cb0ef41Sopenharmony_ci 351cb0ef41Sopenharmony_ciconst buffer = Buffer.from(compressedString, 'base64'); 361cb0ef41Sopenharmony_cizlib.brotliDecompress(buffer, common.mustCall((err, buffer) => { 371cb0ef41Sopenharmony_ci assert.strictEqual(buffer.toString(), inputString); 381cb0ef41Sopenharmony_ci})); 39