mirror of
https://gitee.com/Lyon1998/pikapython.git
synced 2025-01-15 17:02:53 +08:00
add test_tuple_nested test.
This commit is contained in:
parent
d63ff577a2
commit
3f0f1680dc
2
port/linux/package/pikascript/_testcase.pyi
Normal file
2
port/linux/package/pikascript/_testcase.pyi
Normal file
@ -0,0 +1,2 @@
|
||||
|
||||
def test_tuple_nested(tuple_nasted: tuple): ...
|
@ -4,7 +4,7 @@ import pika_lua, pika_cjson, cjson_test, json
|
||||
import GTestTask, TempDevTest
|
||||
import cb_test
|
||||
import configparser, network, math, struct
|
||||
import test_module1, test_cmodule, test_module4, import_test
|
||||
import test_module1, test_cmodule, test_module4, import_test, testcase
|
||||
import hashlib, hmac, aes, base64, time, os, zlib
|
||||
import _thread, weakref, eventloop
|
||||
import this
|
||||
|
@ -0,0 +1,27 @@
|
||||
#include "_testcase.h"
|
||||
|
||||
void _testcase_test_tuple_nested(PikaObj* self, PikaObj* tuple_nasted) {
|
||||
size_t len = pikaTuple_getSize(tuple_nasted);
|
||||
for (size_t i = 0; i < len; i++) {
|
||||
Arg* item = pikaTuple_get(tuple_nasted, i);
|
||||
if (arg_isTuple(item)) {
|
||||
PikaObj* tuple_inner = arg_getObj(item);
|
||||
size_t len_inner = pikaTuple_getSize(tuple_inner);
|
||||
for (size_t j = 0; j < len_inner; j++) {
|
||||
Arg* item_inner = pikaTuple_get(tuple_inner, j);
|
||||
if (ARG_TYPE_INT == arg_getType(item_inner)) {
|
||||
int64_t value = arg_getInt(item_inner);
|
||||
pika_platform_printf("[%d, %d] %ld\n", i, j, value);
|
||||
}
|
||||
if (ARG_TYPE_FLOAT == arg_getType(item_inner)) {
|
||||
double value = arg_getFloat(item_inner);
|
||||
pika_platform_printf("[%d, %d] %f\n", i, j, value);
|
||||
}
|
||||
if (ARG_TYPE_STRING == arg_getType(item_inner)) {
|
||||
char* value = arg_getStr(item_inner);
|
||||
pika_platform_printf("[%d, %d] %s\n", i, j, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
5
port/linux/package/pikascript/testcase.py
Normal file
5
port/linux/package/pikascript/testcase.py
Normal file
@ -0,0 +1,5 @@
|
||||
import _testcase
|
||||
|
||||
def test_tuple_nested():
|
||||
student_records = ((12345, "Alice"), (67890, "Bob"))
|
||||
_testcase.test_tuple_nested(student_records)
|
@ -2,4 +2,4 @@
|
||||
#define PIKA_VERSION_MINOR 12
|
||||
#define PIKA_VERSION_MICRO 5
|
||||
|
||||
#define PIKA_EDIT_TIME "2023/08/29 13:56:27"
|
||||
#define PIKA_EDIT_TIME "2023/09/06 22:57:32"
|
||||
|
Loading…
x
Reference in New Issue
Block a user