Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: increase coverage for buffer.js #12476

Closed
wants to merge 1 commit into from
Closed

Conversation

Trott
Copy link
Member

@Trott Trott commented Apr 17, 2017

Add coverage for non-numeric byteOffset and length when using
Buffer.from() with an ArrayBuffer.

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • commit message follows commit guidelines
Affected core subsystem(s)

test buffer

@Trott Trott added buffer Issues and PRs related to the buffer subsystem. test Issues and PRs related to the tests. labels Apr 17, 2017
Copy link
Contributor

@cjihrig cjihrig left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if byteoffset in the comment should be byteOffset, but either way, LGTM.

const ab = new ArrayBuffer(10);
const buf = Buffer.from(ab, 0, 'fhqwhgads');
assert.deepStrictEqual(buf, Buffer.from(ab, 0, 0));
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is fine, but it may be worthwhile to test additional non-numeric inputs (object, array, NaN, etc).

For instance:

  • Buffer.from(ab, NaN), offset defaults to 0
  • Buffer.from(ab, Infinity) throws
  • Buffer.from(ab, {}) offset defaults to 0
  • Buffer.from(ab, []) offset defaults to 0
  • Buffer.from(ab, [1]) ``offset is 1

etc...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added these. PTAL. Thanks.

Add coverage for non-numeric byteOffset and length when using
Buffer.from() with an ArrayBuffer.
@Trott
Copy link
Member Author

Trott commented Apr 18, 2017

@cjihrig Updated the comment. Thanks.

@Trott
Copy link
Member Author

Trott commented Apr 18, 2017

@jasnell
Copy link
Member

jasnell commented Apr 19, 2017

Failure in CI is unrelated.

jasnell pushed a commit that referenced this pull request Apr 19, 2017
Add coverage for non-numeric byteOffset and length when using
Buffer.from() with an ArrayBuffer.

PR-URL: #12476
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: James M Snell <[email protected]>
@jasnell
Copy link
Member

jasnell commented Apr 19, 2017

LAnded in d78fd26

@jasnell jasnell closed this Apr 19, 2017
evanlucas pushed a commit that referenced this pull request Apr 25, 2017
Add coverage for non-numeric byteOffset and length when using
Buffer.from() with an ArrayBuffer.

PR-URL: #12476
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: James M Snell <[email protected]>
@evanlucas evanlucas mentioned this pull request May 1, 2017
evanlucas pushed a commit that referenced this pull request May 1, 2017
Add coverage for non-numeric byteOffset and length when using
Buffer.from() with an ArrayBuffer.

PR-URL: #12476
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: James M Snell <[email protected]>
evanlucas pushed a commit that referenced this pull request May 2, 2017
Add coverage for non-numeric byteOffset and length when using
Buffer.from() with an ArrayBuffer.

PR-URL: #12476
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: James M Snell <[email protected]>
gibfahn pushed a commit that referenced this pull request May 16, 2017
Add coverage for non-numeric byteOffset and length when using
Buffer.from() with an ArrayBuffer.

PR-URL: #12476
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: James M Snell <[email protected]>
MylesBorins pushed a commit that referenced this pull request May 18, 2017
Add coverage for non-numeric byteOffset and length when using
Buffer.from() with an ArrayBuffer.

PR-URL: #12476
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: James M Snell <[email protected]>
@MylesBorins MylesBorins mentioned this pull request May 23, 2017
andrew749 pushed a commit to michielbaird/node that referenced this pull request Jul 19, 2017
Add coverage for non-numeric byteOffset and length when using
Buffer.from() with an ArrayBuffer.

PR-URL: nodejs/node#12476
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: James M Snell <[email protected]>
@Trott Trott deleted the arraybuffer branch January 13, 2022 22:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
buffer Issues and PRs related to the buffer subsystem. test Issues and PRs related to the tests.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants