+ Fixed build for mac
+ Removed undefined properties from tests
This commit is contained in:
Mikhail Lobotskiy
2023-11-16 18:19:43 +04:00
committed by Mikhail Lobotskiy
parent c23eece6ae
commit 84c34eed65
2 changed files with 11 additions and 4 deletions

View File

@ -14,9 +14,9 @@ namespace NSJSON
{
class IBaseValue;
// Transform C++ value to JS value
JSSmart<NSJSBase::CJSValue> toJS(const IBaseValue* pValue);
static JSSmart<NSJSBase::CJSValue> toJS(const IBaseValue* pValue);
// Transform JS value to C++ value
IBaseValue* fromJS(JSSmart<NSJSBase::CJSValue> jsValue);
static IBaseValue* fromJS(JSSmart<NSJSBase::CJSValue> jsValue);
class JS_DECL IBaseValue
{

View File

@ -87,14 +87,21 @@ TEST_F(CGetPropertyNamesTest, inner_object)
TEST_F(CGetPropertyNamesTest, object_with_null_and_undefined_properties)
{
std::vector<std::string> result = getObjectProperties("{number: null, name: undefined, func() { return 'bar'; }}");
std::vector<std::string> expected = {"number", "name", "func"};
std::vector<std::string> expected = {"number", "func"};
EXPECT_TRUE(compare(result, expected)) << printInfo("Actual: ", result) << printInfo("Expected: ", expected);
}
TEST_F(CGetPropertyNamesTest, object_with_only_undefined_properties)
{
std::vector<std::string> result = getObjectProperties("{foo: undefined, bar: undefined}");
std::vector<std::string> expected = {};
EXPECT_TRUE(compare(result, expected)) << printInfo("Actual: ", result) << printInfo("Expected: ", expected);
}
TEST_F(CGetPropertyNamesTest, array_as_object)
{
std::vector<std::string> result = getObjectProperties("{0: 4, 1: 2, 2: undefined, 3: 'foo', 42: 'bar'}");
std::vector<std::string> expected = {"0", "1", "2", "3", "42"};
std::vector<std::string> expected = {"0", "1", "3", "42"};
EXPECT_TRUE(compare(result, expected)) << printInfo("Actual: ", result) << printInfo("Expected: ", expected);
}