diff --git a/test/test_convert.cpp b/test/test_convert.cpp index 41825a5b..2e12df54 100644 --- a/test/test_convert.cpp +++ b/test/test_convert.cpp @@ -110,7 +110,7 @@ struct convert { if (!is_valid(isolate, value)) { - throw std::runtime_error("excpected object"); + throw std::runtime_error("expected object"); } v8::HandleScope scope(isolate); @@ -153,6 +153,8 @@ void test_convert() #ifdef WIN32 test_string_conv(isolate, L"qaz"); #endif + // numeric string + test_string_conv(isolate, "0"); const std::vector vector{ 1, 2, 3 }; test_conv(isolate, vector); @@ -170,7 +172,7 @@ void test_convert() test_conv(isolate, std::map{ { 'a', 1 }, { 'b', 2 }, { 'c', 3 } }); test_conv(isolate, std::multimap{ { 1, -1 }, { 2, -2 } }); test_conv(isolate, std::unordered_map{ { 'x', "1" }, { 'y', "2" } }); - test_conv(isolate, std::unordered_multimap{ { "a", 1 }, { "b", 2 } }); + test_conv(isolate, std::unordered_multimap{ { "0", 0 }, { "a", 1 }, { "b", 2 } }); check_eq("initializer list to array", v8pp::from_v8>(isolate, v8pp::to_v8(isolate, { 1, 2, 3 })), vector); diff --git a/v8pp/convert.hpp b/v8pp/convert.hpp index f7535d48..af2a8b79 100644 --- a/v8pp/convert.hpp +++ b/v8pp/convert.hpp @@ -60,7 +60,7 @@ struct convert::value> static bool is_valid(v8::Isolate*, v8::Local value) { - return !value.IsEmpty() && value->IsString(); + return !value.IsEmpty() && (value->IsString() || value->IsNumber()); } static from_type from_v8(v8::Isolate* isolate, v8::Local value)