pikapython/test/ctypes-test.cpp

38 lines
924 B
C
Raw Normal View History

2022-06-10 11:34:46 +08:00
#include "test_common.h"
TEST_START
2022-06-10 11:34:46 +08:00
#if PIKA_SYNTAX_SLICE_ENABLE
2022-06-10 11:34:46 +08:00
TEST(ctypes, test1) {
/* init */
g_PikaMemInfo.heapUsedMax = 0;
2022-06-10 11:34:46 +08:00
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
2023-01-27 23:00:53 +08:00
#if !PIKA_NANO_ENABLE
2022-06-10 11:34:46 +08:00
TEST(ctypes, test2) {
/* init */
g_PikaMemInfo.heapUsedMax = 0;
2022-06-10 11:34:46 +08:00
PikaObj* pikaMain = newRootObj("pikaMain", New_PikaMain);
/* run */
obj_run(pikaMain,
"len(b'test\\x0')\n"
2023-01-26 15:58:58 +08:00
"len(b'test\\x0'.decode())\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);
}
2023-01-27 23:00:53 +08:00
#endif
TEST_END