Sha256: de4dcd9adafa570728c36514c1c9981bb4c2710a593ae77fce3809e16a4b472e

Contents?: true

Size: 1.05 KB

Versions: 62

Compression:

Stored size: 1.05 KB

Contents

var B = require('../').Buffer
var test = require('tape')
if (process.env.OBJECT_IMPL) B.TYPED_ARRAY_SUPPORT = false


test('detect utf16 surrogate pairs', function(t) {
  var text = '\uD83D\uDE38' + '\uD83D\uDCAD' + '\uD83D\uDC4D'
  var buf = new B(text)
  t.equal(text, buf.toString())
  t.end()
})

test('throw on orphaned utf16 surrogate lead code point', function(t) {
  var text = '\uD83D\uDE38' + '\uD83D' + '\uD83D\uDC4D'
  var err
  try {
    var buf = new B(text)
  } catch (e) {
    err = e
  }
  t.equal(err instanceof URIError, true)
  t.end()
})

test('throw on orphaned utf16 surrogate trail code point', function(t) {
  var text = '\uD83D\uDE38' + '\uDCAD' + '\uD83D\uDC4D'
  var err
  try {
    var buf = new B(text)
  } catch (e) {
    err = e
  }
  t.equal(err instanceof URIError, true)
  t.end()
})

test('do not write partial utf16 code units', function(t) {
  var f = new B([0, 0, 0, 0, 0])
  t.equal(f.length, 5)
  var size = f.write('あいうえお', 'utf16le')
  t.equal(size, 4)
  t.deepEqual(f, new B([0x42, 0x30, 0x44, 0x30, 0x00]))
  t.end()
})

Version data entries

62 entries across 62 versions & 1 rubygems

Version Path
smock-0.1.268 node_modules/webpack/node_modules/node-libs-browser/node_modules/buffer/test/utf16.js
smock-0.1.267 node_modules/webpack/node_modules/node-libs-browser/node_modules/buffer/test/utf16.js
smock-0.1.266 node_modules/webpack/node_modules/node-libs-browser/node_modules/buffer/test/utf16.js
smock-0.1.265 node_modules/webpack/node_modules/node-libs-browser/node_modules/buffer/test/utf16.js
smock-0.1.264 node_modules/webpack/node_modules/node-libs-browser/node_modules/buffer/test/utf16.js
smock-0.1.263 node_modules/webpack/node_modules/node-libs-browser/node_modules/buffer/test/utf16.js
smock-0.1.262 node_modules/webpack/node_modules/node-libs-browser/node_modules/buffer/test/utf16.js
smock-0.1.261 node_modules/webpack/node_modules/node-libs-browser/node_modules/buffer/test/utf16.js
smock-0.1.260 node_modules/webpack/node_modules/node-libs-browser/node_modules/buffer/test/utf16.js
smock-0.1.259 node_modules/webpack/node_modules/node-libs-browser/node_modules/buffer/test/utf16.js
smock-0.1.258 node_modules/webpack/node_modules/node-libs-browser/node_modules/buffer/test/utf16.js
smock-0.1.256 node_modules/webpack/node_modules/node-libs-browser/node_modules/buffer/test/utf16.js
smock-0.1.255 node_modules/webpack/node_modules/node-libs-browser/node_modules/buffer/test/utf16.js
smock-0.1.254 node_modules/webpack/node_modules/node-libs-browser/node_modules/buffer/test/utf16.js
smock-0.1.253 node_modules/webpack/node_modules/node-libs-browser/node_modules/buffer/test/utf16.js
smock-0.1.252 node_modules/webpack/node_modules/node-libs-browser/node_modules/buffer/test/utf16.js
smock-0.1.251 node_modules/webpack/node_modules/node-libs-browser/node_modules/buffer/test/utf16.js
smock-0.1.250 node_modules/webpack/node_modules/node-libs-browser/node_modules/buffer/test/utf16.js
smock-0.1.249 node_modules/webpack/node_modules/node-libs-browser/node_modules/buffer/test/utf16.js
smock-0.1.247 node_modules/webpack/node_modules/node-libs-browser/node_modules/buffer/test/utf16.js