unable get string length
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 35/100
Research direction
Start with the napi_get_value_string_utf8 call in the addon method and tests/1-test.js; compare the shown invocation with the API's expected arguments. Run the hello test and confirm the echo path obtains the string length without reporting an error.
Written by the indexing model from the issue text.
Description
I am now testing for echo function,
for code
napi_value Method(napi_env env, napi_callback_info args)
{
// napi_value str;
napi_status status;
cout << "inside method!" << endl;
size_t argc = 0;
napi_value argv[1];
status = napi_get_cb_info(env, args, &argc, argv, nullptr, nullptr);
if (status != napi_ok)
{
napi_throw_error(env, NULL, "Error Get Parameters!");
return nullptr;
}
cout << "before argc!" << endl;
if (argc < 1)
{
cout << "" << endl;
return nullptr;
}
size_t strlen;
status = napi_get_value_string_utf8(env, argv[0], NULL, 0, &strlen);
if (status != napi_ok)
{
napi_throw_error(env, NULL, "Error Get String Length!");
return nullptr;
}
// status = napi_create_string_utf8(env, argv[0], NAPI_AUTO_LENGTH, res);
// if (status != napi_ok)
// {
// napi_throw_error(env, NULL, "Error Get String!");
// return nullptr;
// }
return nullptr;
}
and
status = napi_set_named_property(env, exports, "echo", fn);
and
echo('hello!')
,
I got:
inside method!
before argc!
before get string!
�"�d2
1) hello
0 passing (11ms)
1 failing
1) crypto
hello:
Error: Error Get String Length!
at Context.it (tests/1-test.js:4:24)
- Dominant language
- C++
- Stars
- 2.6k
- Forks
- 602
- PR merge metrics
- No merged PRs in 30d
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from nodejs/node-addon-examples
-
enhancement
Difficulty 4/5 3-5 days Newbie friendliness 38/100
nodejs/node-addon-examples#585 · 1 reaction ·
-
Difficulty 3/5 1-2 days Newbie friendliness 38/100
nodejs/node-addon-examples#530 · 1 comment ·
-
Difficulty 4/5 3-5 days Newbie friendliness 35/100
nodejs/node-addon-examples#445 ·
-
Difficulty 3/5 1-2 days Newbie friendliness 32/100
nodejs/node-addon-examples#444 · 1 comment ·
-
Difficulty 3/5 1-2 days Newbie friendliness 35/100
nodejs/node-addon-examples#381 ·
All issues in nodejs/node-addon-examples
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
-
Sensor initialization takes very long when `--initial-sim-time` is set to current UNIX timestamp Open
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
gazebosim/gz-sensors#662 · 1 comment ·
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
-
comp-datalake
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
ClickHouse/ClickHouse#121222 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
LadybirdBrowser/ladybird#12123 ·