add test_tuple_nested test.

This commit is contained in:
Lyon 2023-09-06 22:58:28 +08:00
parent d63ff577a2
commit 3f0f1680dc
5 changed files with 36 additions and 2 deletions

View File

@ -0,0 +1,2 @@
def test_tuple_nested(tuple_nasted: tuple): ...

View File

@ -4,7 +4,7 @@ import pika_lua, pika_cjson, cjson_test, json
import GTestTask, TempDevTest import GTestTask, TempDevTest
import cb_test import cb_test
import configparser, network, math, struct 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 hashlib, hmac, aes, base64, time, os, zlib
import _thread, weakref, eventloop import _thread, weakref, eventloop
import this import this

View File

@ -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);
}
}
}
}
}

View File

@ -0,0 +1,5 @@
import _testcase
def test_tuple_nested():
student_records = ((12345, "Alice"), (67890, "Bob"))
_testcase.test_tuple_nested(student_records)

View File

@ -2,4 +2,4 @@
#define PIKA_VERSION_MINOR 12 #define PIKA_VERSION_MINOR 12
#define PIKA_VERSION_MICRO 5 #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"