mirror of
https://gitee.com/Lyon1998/pikapython.git
synced 2025-01-15 17:02:53 +08:00
more test for obj_set_str(NULL)
This commit is contained in:
parent
b4a79e00dd
commit
24862b7215
@ -21,3 +21,6 @@ def test_raise(): ...
|
||||
class ProxyTest:
|
||||
def __getattribute__(self, __name: str) -> any: ...
|
||||
def __setattr__(self, __name: str, __value: any): ...
|
||||
|
||||
class _test:
|
||||
def __init__(self):...
|
||||
|
@ -63,3 +63,7 @@ void GTestTask_ProxyTest___setattr__(PikaObj* self,
|
||||
void GTestTask_test_raise(PikaObj *self){
|
||||
obj_setErrorCode(self, 1);
|
||||
}
|
||||
|
||||
void GTestTask__test___init__(PikaObj *self){
|
||||
obj_setStr(self, "a", NULL);
|
||||
}
|
||||
|
@ -180,14 +180,12 @@ PIKA_RES obj_setFloat(PikaObj* self, char* argPath, pika_float value) {
|
||||
}
|
||||
|
||||
PIKA_RES obj_setStr(PikaObj* self, char* argPath, char* str) {
|
||||
pika_assert(NULL != str);
|
||||
PikaObj* obj = obj_getHostObj(self, argPath);
|
||||
if (NULL == obj) {
|
||||
return PIKA_RES_ERR_ARG_NO_FOUND;
|
||||
}
|
||||
char* name = strPointToLastToken(argPath, '.');
|
||||
args_setStr(obj->list, name, str);
|
||||
return PIKA_RES_OK;
|
||||
return args_setStr(obj->list, name, str);
|
||||
}
|
||||
|
||||
PIKA_RES obj_setNone(PikaObj* self, char* argPath) {
|
||||
|
@ -85,7 +85,6 @@ PIKA_RES args_setRef(Args* self, char* name, void* argPointer) {
|
||||
}
|
||||
|
||||
PIKA_RES args_setStr(Args* self, char* name, char* strIn) {
|
||||
pika_assert(NULL != strIn);
|
||||
PIKA_RES errCode = PIKA_RES_OK;
|
||||
Arg* argNew = New_arg(NULL);
|
||||
argNew = arg_setStr(argNew, name, strIn);
|
||||
|
@ -2839,4 +2839,26 @@ TEST(pikaMain, obj_setNone) {
|
||||
EXPECT_EQ(pikaMemNow(), 0);
|
||||
}
|
||||
|
||||
TEST(pikaMain, obj_setStr_NULL) {
|
||||
PikaObj* pikaMain = newRootObj("pikaMain", New_PikaMain);
|
||||
obj_setStr(pikaMain, "n", NULL);
|
||||
obj_run(pikaMain, "print(n)");
|
||||
EXPECT_STREQ(log_buff[2], "NameError: name 'n' is not defined\r\n");
|
||||
obj_deinit(pikaMain);
|
||||
EXPECT_EQ(pikaMemNow(), 0);
|
||||
}
|
||||
|
||||
TEST(pikaMain, _obj_set_str_null) {
|
||||
PikaObj* pikaMain = newRootObj("pikaMain", New_PikaMain);
|
||||
extern unsigned char pikaModules_py_a[];
|
||||
obj_linkLibrary(pikaMain, pikaModules_py_a);
|
||||
obj_run(pikaMain,
|
||||
"class _test(GTestTask._test):\n"
|
||||
" def __init__(self):\n"
|
||||
" super().__init__()\n"
|
||||
"t = _test()\n");
|
||||
obj_deinit(pikaMain);
|
||||
EXPECT_EQ(pikaMemNow(), 0);
|
||||
}
|
||||
|
||||
TEST_END
|
Loading…
x
Reference in New Issue
Block a user