Use static cast
This commit is contained in:
parent
76c70481e4
commit
6aa6dfe35f
|
@ -19,7 +19,7 @@
|
||||||
#define JS_NULL env.Null()
|
#define JS_NULL env.Null()
|
||||||
#define JS_STR(VAL) Napi::String::New(env, VAL)
|
#define JS_STR(VAL) Napi::String::New(env, VAL)
|
||||||
#define JS_NUM(VAL) Napi::Number::New(env, static_cast<double>(VAL))
|
#define JS_NUM(VAL) Napi::Number::New(env, static_cast<double>(VAL))
|
||||||
#define JS_EXT(VAL) Napi::External<void>::New(env, (void*)(VAL))
|
#define JS_EXT(VAL) Napi::External<void>::New(env, static_cast<void*>(VAL))
|
||||||
#define JS_BOOL(VAL) Napi::Boolean::New(env, static_cast<bool>(VAL))
|
#define JS_BOOL(VAL) Napi::Boolean::New(env, static_cast<bool>(VAL))
|
||||||
#define JS_OBJECT Napi::Object::New(env)
|
#define JS_OBJECT Napi::Object::New(env)
|
||||||
#define JS_ARRAY Napi::Array::New(env)
|
#define JS_ARRAY Napi::Array::New(env)
|
||||||
|
|
|
@ -6,10 +6,22 @@ const test = require('./build/Release/test.node');
|
||||||
|
|
||||||
describe('Function arguments', () => {
|
describe('Function arguments', () => {
|
||||||
|
|
||||||
it('can require 3 args / REQ_ARGS', () => {
|
describe('REQ_ARGS', () => {
|
||||||
expect(test.reqArgs3).to.be.a('function');
|
it('exports reqArgs3', () => {
|
||||||
expect(() => test.reqArgs3(1)).to.throw('Expected at least 3 arguments');
|
expect(test.reqArgs3).to.be.a('function');
|
||||||
expect(test.reqArgs3(1, 2, 3)).to.be.true;
|
});
|
||||||
|
it('throws if no args passed', () => {
|
||||||
|
expect(() => test.reqArgs3()).to.throw('Expected at least 3 arguments');
|
||||||
|
});
|
||||||
|
it('throws if 1 arg passed', () => {
|
||||||
|
expect(() => test.reqArgs3(1)).to.throw('Expected at least 3 arguments');
|
||||||
|
});
|
||||||
|
it('returns true if 3 args passed', () => {
|
||||||
|
expect(test.reqArgs3(1, 2, 3)).to.be.true;
|
||||||
|
});
|
||||||
|
it('returns true if 5 args passed', () => {
|
||||||
|
expect(test.reqArgs3(1, 2, 3, 4, 5)).to.be.true;
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('IS_ARG_EMPTY', () => {
|
describe('IS_ARG_EMPTY', () => {
|
||||||
|
|
Loading…
Reference in New Issue