2022-01-07 12:32:58 +08:00
|
|
|
#include "tkc/fscript.h"
|
|
|
|
#include "tkc/object_default.h"
|
|
|
|
#include "gtest/gtest.h"
|
|
|
|
|
|
|
|
TEST(FScriptArray, size) {
|
|
|
|
value_t v;
|
|
|
|
tk_object_t* obj = object_default_create();
|
|
|
|
|
|
|
|
fscript_eval(obj, "a=array_create();array_push(a, 1);array_push(a, 2);array_size(a)", &v);
|
|
|
|
ASSERT_EQ(value_uint32(&v), 2);
|
|
|
|
value_reset(&v);
|
2022-01-16 18:15:14 +08:00
|
|
|
|
2022-01-07 12:32:58 +08:00
|
|
|
fscript_eval(obj, "a=array_create();array_is_empty(a)", &v);
|
|
|
|
ASSERT_EQ(value_bool(&v), TRUE);
|
|
|
|
value_reset(&v);
|
2022-01-16 18:15:14 +08:00
|
|
|
|
2022-01-07 12:32:58 +08:00
|
|
|
fscript_eval(obj, "a=array_create();array_push(a, 1);array_push(a, 2);array_is_empty(a)", &v);
|
|
|
|
ASSERT_EQ(value_bool(&v), FALSE);
|
|
|
|
value_reset(&v);
|
|
|
|
|
|
|
|
TK_OBJECT_UNREF(obj);
|
|
|
|
}
|