Added tests to basic CValue functionality

This commit is contained in:
Mikhail Lobotskiy
2023-11-27 21:29:56 +04:00
parent 2d9206b79b
commit 3e5eb3d251
4 changed files with 475 additions and 10 deletions

View File

@ -318,6 +318,9 @@ namespace NSJSON
CValue CValue::CreateArray(int count)
{
CValue ret;
if (count < 0)
return ret;
ret.m_internal->m_value = std::make_shared<CArray>(count);
ret.m_internal->m_type = CTypedValue::vtArray;
return ret;
@ -326,6 +329,9 @@ namespace NSJSON
CValue CValue::CreateTypedArray(BYTE* data, int count, bool isExternalize)
{
CValue ret;
if (count <= 0)
return ret;
ret.m_internal->m_value = std::make_shared<CTypedArray>(data, count, isExternalize);
ret.m_internal->m_type = CTypedValue::vtTypedArray;
return ret;

View File

@ -125,7 +125,7 @@ namespace NSJSON
if (m_type == ptDouble)
return m_double;
if (m_type == ptInteger)
return (double)m_double;
return (double)m_int;
#ifdef JSON_DEBUG
throw std::bad_cast();
#endif