Skip to content

Commit f0d0c2f

Browse files
committed
test(functions): 添加数组参数调用功能测试
- 在base.cpp中新增call_array测试用例,验证substr_compare函数的数组参数调用 - 在object.cpp中新增call_array测试用例,验证DateTime类setTime方法的数组参数调用 - 测试覆盖普通函数和对象方法的数组参数传递场景 - 验证数组参数能够正确传递给底层函数执行
1 parent 2cb52d9 commit f0d0c2f

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

tests/src/base.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -388,3 +388,10 @@ TEST(base, getPropertyOffset) {
388388
try_call([]() { auto offset1 = getPropertyOffset("TestClassNotExists", "propXt"); },
389389
"class 'TestClassNotExists' is undefined.");
390390
}
391+
392+
TEST(base, call_array) {
393+
auto fn = getFunction("substr_compare");
394+
Array arr({"abcde", "bc", 1, 3});
395+
auto rs = call(fn, arr);
396+
ASSERT_EQ(rs.toInt(), 1);
397+
}

tests/src/object.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -610,3 +610,12 @@ TEST(object, exec) {
610610
auto rs2 = obj.exec(fn2);
611611
ASSERT_GT(rs2.toInt(), 100000000);
612612
}
613+
614+
TEST(object, call_array) {
615+
auto obj = newObject("DateTime", "2000-01-01");
616+
auto fn = getMethod(obj.ce(), "setTime");
617+
Array arr({10, 10, 10});
618+
obj.exec(fn, arr);
619+
auto rs = obj.exec("format", "Y-m-d H:i:s");
620+
ASSERT_STREQ(rs.toCString(), "2000-01-01 10:10:10");
621+
}

0 commit comments

Comments
 (0)