awtk/tests/fscript_json_test.cc

27 lines
577 B
C++
Raw Normal View History

2022-05-13 17:04:04 +08:00
#include "tkc/fscript.h"
#include "tkc/object_default.h"
#include "gtest/gtest.h"
TEST(FExr, json1) {
value_t v;
tk_object_t* obj = object_default_create();
fscript_eval(obj, "a=json_load('{\"value\":123}');object_get(a, 'value')", &v);
ASSERT_EQ(value_uint32(&v), 123);
value_reset(&v);
TK_OBJECT_UNREF(obj);
}
TEST(FExr, json2) {
value_t v;
tk_object_t* obj = object_default_create();
fscript_eval(obj, "a=json_load('{\"value\":123}', 14);object_get(a, 'value')", &v);
ASSERT_EQ(value_uint32(&v), 123);
value_reset(&v);
TK_OBJECT_UNREF(obj);
}