summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorAlexey Orlenko <eaglexrlnk@gmail.com>2017-03-25 19:39:12 +0200
committerJames M Snell <jasnell@gmail.com>2017-03-27 10:28:25 -0700
commit52b666ee3dd4beb76d7862337e54a35959799c1e (patch)
tree2436bce76720938e2c99996709390eeb17af88c8 /test
parent45df578f623819d25ca21d46a0d6086f1c04ff1d (diff)
downloadandroid-node-v8-52b666ee3dd4beb76d7862337e54a35959799c1e.tar.gz
android-node-v8-52b666ee3dd4beb76d7862337e54a35959799c1e.tar.bz2
android-node-v8-52b666ee3dd4beb76d7862337e54a35959799c1e.zip
test: fix broken tests in test-buffer-includes
Some of the tests for `buffer.includes()` functionality introduced in https://github.com/nodejs/node/pull/3567 have been broken in a way that caused them to always pass regardless of the result of the tested method. This behavior was caused by two reasons: * These tests were written as though `buffer.includes()` was supposed to return the same value that `buffer.indexOf()` does, i.e., used indices or -1 as expected return values instead of true and false. * `assert()` was used as the assertion function to do that instead of `assert.strictEqual()`. Thus `assert()` was called with a non-zero number as the first argument effectively causing these tests to pass. This commit changes the tests to use `assert.ok()` and removes redundant indices. PR-URL: https://github.com/nodejs/node/pull/12040 Ref: https://github.com/nodejs/node/pull/3567 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Yuta Hiroto <hello@about-hiroppy.com> Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'test')
-rw-r--r--test/parallel/test-buffer-includes.js22
1 files changed, 10 insertions, 12 deletions
diff --git a/test/parallel/test-buffer-includes.js b/test/parallel/test-buffer-includes.js
index 0fa5665b36..9b80d56782 100644
--- a/test/parallel/test-buffer-includes.js
+++ b/test/parallel/test-buffer-includes.js
@@ -155,14 +155,12 @@ assert(mixedByteStringUcs2.includes('bc', 0, 'ucs2'));
assert(mixedByteStringUcs2.includes('\u03a3', 0, 'ucs2'));
assert(!mixedByteStringUcs2.includes('\u0396', 0, 'ucs2'));
-assert(
- 6, mixedByteStringUcs2.includes(Buffer.from('bc', 'ucs2'), 0, 'ucs2'));
-assert(
- 10, mixedByteStringUcs2.includes(Buffer.from('\u03a3', 'ucs2'),
- 0, 'ucs2'));
-assert(
- -1, mixedByteStringUcs2.includes(Buffer.from('\u0396', 'ucs2'),
- 0, 'ucs2'));
+assert.ok(
+ mixedByteStringUcs2.includes(Buffer.from('bc', 'ucs2'), 0, 'ucs2'));
+assert.ok(
+ mixedByteStringUcs2.includes(Buffer.from('\u03a3', 'ucs2'), 0, 'ucs2'));
+assert.ok(
+ !mixedByteStringUcs2.includes(Buffer.from('\u0396', 'ucs2'), 0, 'ucs2'));
twoByteString = Buffer.from('\u039a\u0391\u03a3\u03a3\u0395', 'ucs2');
@@ -266,12 +264,12 @@ for (let lengthIndex = 0; lengthIndex < lengths.length; lengthIndex++) {
const patternBufferUcs2 =
allCharsBufferUcs2.slice(index, index + length);
- assert(
- index, allCharsBufferUcs2.includes(patternBufferUcs2, 0, 'ucs2'));
+ assert.ok(
+ allCharsBufferUcs2.includes(patternBufferUcs2, 0, 'ucs2'));
const patternStringUcs2 = patternBufferUcs2.toString('ucs2');
- assert(
- index, allCharsBufferUcs2.includes(patternStringUcs2, 0, 'ucs2'));
+ assert.ok(
+ allCharsBufferUcs2.includes(patternStringUcs2, 0, 'ucs2'));
}
}