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

tests: add operator overloading tests for Number class #355

Closed
wants to merge 3 commits into from

Conversation

nadongguri
Copy link
Contributor

@nadongguri nadongguri commented Sep 25, 2018

Hi node-addon-api members,

in this PR, I added tests for checking operator overloading for Number class.

class methods
Number operator int32_t() const
  operator uint32_t() const
  operator int64_t() const
  operator float() const
  operator double() const

Please review and suggest some other test cases. See the issue #332.

@NickNaso
Copy link
Member

Hi @nadongguri,
I just taken a look at your tests and they seem good. Maybe you can add the following test:

  • Empty Napi::Number using Napi::Number() in this case you can use the method Napi::Value::IsEmpty() to check the object you created is empty or not.

  • Create a new Napi::Number object from another using constructor that take as parameters napi_env and napi_value (Napi::Number(napi_env env, napi_value value)). Maybe you can pass a Number to a function and create a new Napi::Number then return it to JavaScript and check if it is equal or not to your initial value.

Hope you agree with my proposal. Keep me updated. Thanks for your contribution.

@nadongguri
Copy link
Contributor Author

Hi @NickNaso,
thanks for your comment. I'll surely add those tests.

@nadongguri
Copy link
Contributor Author

Hi @NickNaso,
I added these tests based on your guide. :)

class methods
Number Number()
  Number(napi_env env, napi_value value)

Copy link
Member

@mhdawson mhdawson left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Member

@NickNaso NickNaso left a comment

Choose a reason for hiding this comment

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

LGTM @nadongguri Good work!

mhdawson pushed a commit that referenced this pull request Sep 28, 2018
PR-URL: #355
Reviewed-By: Michael Dawson <[email protected]>
Reviewed-By: Nicola Del Gobbo <[email protected]>
@mhdawson
Copy link
Member

landed as 779560f. Thanks @nadongguri

@mhdawson mhdawson closed this Sep 28, 2018
yjaeseok pushed a commit to yjaeseok/node-addon-api that referenced this pull request Oct 1, 2018
PR-URL: nodejs#355
Reviewed-By: Michael Dawson <[email protected]>
Reviewed-By: Nicola Del Gobbo <[email protected]>
kevindavies8 added a commit to kevindavies8/node-addon-api-Develop that referenced this pull request Aug 24, 2022
PR-URL: nodejs/node-addon-api#355
Reviewed-By: Michael Dawson <[email protected]>
Reviewed-By: Nicola Del Gobbo <[email protected]>
Marlyfleitas added a commit to Marlyfleitas/node-api-addon-Development that referenced this pull request Aug 26, 2022
PR-URL: nodejs/node-addon-api#355
Reviewed-By: Michael Dawson <[email protected]>
Reviewed-By: Nicola Del Gobbo <[email protected]>
wroy7860 added a commit to wroy7860/addon-api-benchmark-node that referenced this pull request Sep 19, 2022
PR-URL: nodejs/node-addon-api#355
Reviewed-By: Michael Dawson <[email protected]>
Reviewed-By: Nicola Del Gobbo <[email protected]>
johnfrench3 pushed a commit to johnfrench3/node-addon-api-git that referenced this pull request Aug 11, 2023
PR-URL: nodejs/node-addon-api#355
Reviewed-By: Michael Dawson <[email protected]>
Reviewed-By: Nicola Del Gobbo <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants