summaryrefslogtreecommitdiff
path: root/test/parallel/test-string-decoder.js
diff options
context:
space:
mode:
authorJames M Snell <jasnell@gmail.com>2016-01-25 15:00:06 -0800
committerJames M Snell <jasnell@gmail.com>2016-03-16 08:34:02 -0700
commit85ab4a5f1281c4e1dd06450ac7bd3250326267fa (patch)
tree7a51edfc5d6efc231cf821d575c9ca4a26d0545f /test/parallel/test-string-decoder.js
parent90a5fc20be22b4278a01bc58acba0cb732da0140 (diff)
downloadandroid-node-v8-85ab4a5f1281c4e1dd06450ac7bd3250326267fa.tar.gz
android-node-v8-85ab4a5f1281c4e1dd06450ac7bd3250326267fa.tar.bz2
android-node-v8-85ab4a5f1281c4e1dd06450ac7bd3250326267fa.zip
buffer: add .from(), .alloc() and .allocUnsafe()
Several changes: * Soft-Deprecate Buffer() constructors * Add `Buffer.from()`, `Buffer.alloc()`, and `Buffer.allocUnsafe()` * Add `--zero-fill-buffers` command line option * Add byteOffset and length to `new Buffer(arrayBuffer)` constructor * buffer.fill('') previously had no effect, now zero-fills * Update the docs PR-URL: https://github.com/nodejs/node/pull/4682 Reviewed-By: Сковорода Никита Андреевич <chalkerx@gmail.com> Reviewed-By: Stephen Belanger <admin@stephenbelanger.com>
Diffstat (limited to 'test/parallel/test-string-decoder.js')
-rw-r--r--test/parallel/test-string-decoder.js15
1 files changed, 7 insertions, 8 deletions
diff --git a/test/parallel/test-string-decoder.js b/test/parallel/test-string-decoder.js
index 9d0034e2fc..39f80db9ef 100644
--- a/test/parallel/test-string-decoder.js
+++ b/test/parallel/test-string-decoder.js
@@ -6,10 +6,10 @@ var StringDecoder = require('string_decoder').StringDecoder;
process.stdout.write('scanning ');
// UTF-8
-test('utf-8', new Buffer('$', 'utf-8'), '$');
-test('utf-8', new Buffer('¢', 'utf-8'), '¢');
-test('utf-8', new Buffer('€', 'utf-8'), '€');
-test('utf-8', new Buffer('𤭢', 'utf-8'), '𤭢');
+test('utf-8', Buffer.from('$', 'utf-8'), '$');
+test('utf-8', Buffer.from('¢', 'utf-8'), '¢');
+test('utf-8', Buffer.from('€', 'utf-8'), '€');
+test('utf-8', Buffer.from('𤭢', 'utf-8'), '𤭢');
// A mixed ascii and non-ascii string
// Test stolen from deps/v8/test/cctest/test-strings.cc
// U+02E4 -> CB A4
@@ -19,15 +19,15 @@ test('utf-8', new Buffer('𤭢', 'utf-8'), '𤭢');
// U+3045 -> E3 81 85
test(
'utf-8',
- new Buffer([0xCB, 0xA4, 0x64, 0xE1, 0x8B, 0xA4, 0x30, 0xE3, 0x81, 0x85]),
+ Buffer.from([0xCB, 0xA4, 0x64, 0xE1, 0x8B, 0xA4, 0x30, 0xE3, 0x81, 0x85]),
'\u02e4\u0064\u12e4\u0030\u3045'
);
// UCS-2
-test('ucs2', new Buffer('ababc', 'ucs2'), 'ababc');
+test('ucs2', Buffer.from('ababc', 'ucs2'), 'ababc');
// UTF-16LE
-test('ucs2', new Buffer('3DD84DDC', 'hex'), '\ud83d\udc4d'); // thumbs up
+test('ucs2', Buffer.from('3DD84DDC', 'hex'), '\ud83d\udc4d'); // thumbs up
console.log(' crayon!');
@@ -96,4 +96,3 @@ function writeSequences(length, start, sequence) {
}
return sequences;
}
-