pikapython/test/ctypes-test.cpp

34 lines
867 B
C
Raw Normal View History

2022-06-10 11:34:46 +08:00
#include "test_common.h"
#if PIKA_SYNTAX_SLICE_ENABLE
2022-06-10 11:34:46 +08:00
TEST(ctypes, test1) {
/* init */
pikaMemInfo.heapUsedMax = 0;
PikaObj* pikaMain = newRootObj("pikaMain", New_PikaMain);
/* run */
2022-07-14 13:50:05 +08:00
pikaVM_runSingleFile(pikaMain, "../../examples/BuiltIn/ctypes.py");
2022-06-10 11:34:46 +08:00
/* collect */
/* assert */
2022-09-04 21:19:41 +08:00
EXPECT_STREQ(log_buff[18], "16\r\n");
2022-06-10 11:34:46 +08:00
/* deinit */
obj_deinit(pikaMain);
EXPECT_EQ(pikaMemNow(), 0);
}
#endif
2022-06-10 11:34:46 +08:00
TEST(ctypes, test2) {
/* init */
pikaMemInfo.heapUsedMax = 0;
PikaObj* pikaMain = newRootObj("pikaMain", New_PikaMain);
/* run */
obj_run(pikaMain,
"len(b'test\\x0')\n"
"len(str(b'test\\x0'))\n");
2022-06-10 11:34:46 +08:00
/* collect */
/* assert */
EXPECT_STREQ(log_buff[0], "4\r\n");
EXPECT_STREQ(log_buff[1], "5\r\n");
/* deinit */
obj_deinit(pikaMain);
EXPECT_EQ(pikaMemNow(), 0);
}