2021-10-01 00:21:50 +08:00
|
|
|
#include "gtest/gtest.h"
|
|
|
|
extern "C" {
|
|
|
|
#include "BaseObj.h"
|
|
|
|
#include "PikaStdLib_SysObj.h"
|
|
|
|
#include "TinyObj.h"
|
|
|
|
}
|
|
|
|
|
2021-10-15 11:20:07 +08:00
|
|
|
TEST(sysObj, print) {
|
2021-10-18 11:33:11 +08:00
|
|
|
PikaObj* obj = newRootObj((char*)"test", PikaStdLib_SysObj);
|
2021-10-15 11:20:07 +08:00
|
|
|
Args* res = obj_runDirect(obj, (char*)"print('hello world')");
|
|
|
|
char* sysOut = args_getSysOut(res);
|
|
|
|
int errCode = args_getErrorCode(res);
|
|
|
|
printf("sysout = %s\r\n", sysOut);
|
|
|
|
ASSERT_STREQ((char*)"hello world", sysOut);
|
|
|
|
ASSERT_EQ(0, errCode);
|
|
|
|
args_deinit(res);
|
|
|
|
obj_deinit(obj);
|
|
|
|
EXPECT_EQ(pikaMemNow(), 0);
|
|
|
|
}
|
2021-10-01 00:21:50 +08:00
|
|
|
|
2021-10-15 11:20:07 +08:00
|
|
|
TEST(sysObj, noMethod) {
|
2021-10-18 11:33:11 +08:00
|
|
|
PikaObj* obj = newRootObj((char*)"test", PikaStdLib_SysObj);
|
2021-10-15 11:20:07 +08:00
|
|
|
Args* res = obj_runDirect(obj, (char*)"printttt('hello world')");
|
|
|
|
char* sysOut = args_getSysOut(res);
|
|
|
|
int errCode = args_getErrorCode(res);
|
|
|
|
printf("sysout = %s\r\n", sysOut);
|
|
|
|
ASSERT_EQ(1, strEqu((char*)"[error] runner: method no found.", sysOut));
|
|
|
|
ASSERT_EQ(2, errCode);
|
|
|
|
args_deinit(res);
|
|
|
|
obj_deinit(obj);
|
|
|
|
EXPECT_EQ(pikaMemNow(), 0);
|
|
|
|
}
|