2021-11-03 21:28:37 +08:00
|
|
|
#include "gtest/gtest.h"
|
|
|
|
extern "C" {
|
|
|
|
#include "PikaMain.h"
|
|
|
|
#include "PikaStdLib_MemChecker.h"
|
|
|
|
#include "dataArgs.h"
|
|
|
|
#include "dataMemory.h"
|
|
|
|
#include "pikaScript.h"
|
|
|
|
}
|
|
|
|
extern PikaMemInfo pikaMemInfo;
|
|
|
|
TEST(pikaMain, init) {
|
|
|
|
pikaMemInfo.heapUsedMax = 0;
|
|
|
|
PikaObj* pikaMain = pikaScriptInit();
|
|
|
|
obj_deinit(pikaMain);
|
|
|
|
EXPECT_EQ(pikaMemNow(), 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST(pikaMain, new_mem) {
|
|
|
|
pikaMemInfo.heapUsedMax = 0;
|
|
|
|
PikaObj* pikaMain = newRootObj((char*)"pikaMain", New_PikaMain);
|
|
|
|
Parameters* globals =
|
|
|
|
obj_runDirect(pikaMain, (char*)
|
|
|
|
"mem = PikaStdLib.MemChecker()\n"
|
|
|
|
"mem.max()\n"
|
|
|
|
);
|
2021-11-14 11:42:13 +08:00
|
|
|
PikaObj* mem = (PikaObj*)args_getPtr(globals->list, (char*)"mem");
|
2021-11-03 21:28:37 +08:00
|
|
|
PikaObj* memClassPtr = (PikaObj*)obj_getPtr(mem, (char*)"_clsptr");
|
|
|
|
EXPECT_EQ((void*)memClassPtr, (void*)New_PikaStdLib_MemChecker);
|
|
|
|
obj_deinit(pikaMain);
|
|
|
|
obj_deinit(globals);
|
|
|
|
EXPECT_EQ(pikaMemNow(), 0);
|
|
|
|
}
|