Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
add test case
  • Loading branch information
mawaregetsuka committed Mar 25, 2022
commit 796a7487d87d21dad6906e20394008ae3139a797
10 changes: 8 additions & 2 deletions test/parallel/test-validators.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ const invalidArgValueError = {

// validateInt32() and validateUint32()
[
Symbol(), 1n, {}, [], false, true, undefined, null,
Symbol(), 1n, {}, [], false, true, undefined, null, () => {}, '', '1',
].forEach((val) => assert.throws(() => validateInt32(val, 'name'), {
code: 'ERR_INVALID_ARG_TYPE'
}));
Expand All @@ -56,7 +56,10 @@ const invalidArgValueError = {
code: 'ERR_OUT_OF_RANGE'
}));
[
Symbol(), 1n, {}, [], false, true, undefined, null,
0, 1, -1,
].forEach((val) => validateInt32(val, 'name'));
[
Symbol(), 1n, {}, [], false, true, undefined, null, () => {}, '', '1',
].forEach((val) => assert.throws(() => validateUint32(val, 'name'), {
code: 'ERR_INVALID_ARG_TYPE'
}));
Expand All @@ -65,6 +68,9 @@ const invalidArgValueError = {
].forEach((val) => assert.throws(() => validateUint32(val, 'name'), {
code: 'ERR_OUT_OF_RANGE'
}));
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
}));
}));
// Ensure it doesn't throw on acceptable values:
validateInt32(0, 'name');
validateUint32(0, 'name');
validateInt32(1, 'name');
validateUint32(1, 'name');
validateInt32(-1, 'name');

[
0, 1,
].forEach((val) => validateUint32(val, 'name'));
}

{
Expand Down