mirror of
https://gitee.com/Lyon1998/pikapython.git
synced 2025-01-15 17:02:53 +08:00
6acc0f9ecd
* test for format with tuple is ok * 'format'%var is ok (tuple var is not ok) * rename _cformat to cformat() * optimize the memory usage of format_list * add string-test.cpp * cformat() is ok * fix variable par load issue * use test_common.h * use test_common to simplify the gtest case * Merge branch 'master' into dev * fix float->double for bytecodegen * update to /package * Use double in C for float in python
62 lines
1.4 KiB
C
62 lines
1.4 KiB
C
#include "test_common.h"
|
|
|
|
TEST(stack, NEW) {
|
|
Stack s;
|
|
stack_init(&s);
|
|
stack_deinit(&s);
|
|
EXPECT_EQ(pikaMemNow(), 0);
|
|
}
|
|
|
|
TEST(stack, size) {
|
|
Stack s;
|
|
stack_init(&s);
|
|
|
|
stack_pushSize(&s, 10);
|
|
stack_pushSize(&s, 20);
|
|
stack_pushSize(&s, 30);
|
|
|
|
EXPECT_EQ(stack_popSize(&s), 30);
|
|
EXPECT_EQ(stack_popSize(&s), 20);
|
|
EXPECT_EQ(stack_popSize(&s), 10);
|
|
|
|
stack_deinit(&s);
|
|
EXPECT_EQ(pikaMemNow(), 0);
|
|
}
|
|
|
|
TEST(stack, arg) {
|
|
Stack s;
|
|
stack_init(&s);
|
|
|
|
Arg* arg1 = arg_setInt(NULL, "", 10);
|
|
Arg* arg2 = arg_setInt(NULL, "", 20);
|
|
Arg* arg3 = arg_setInt(NULL, "", 30);
|
|
stack_pushArg(&s, arg1);
|
|
stack_pushArg(&s, arg2);
|
|
stack_pushArg(&s, arg3);
|
|
Arg* arg4 = stack_popArg(&s);
|
|
Arg* arg5 = stack_popArg(&s);
|
|
Arg* arg6 = stack_popArg(&s);
|
|
EXPECT_EQ(arg_getInt(arg4), 30);
|
|
EXPECT_EQ(arg_getInt(arg5), 20);
|
|
EXPECT_EQ(arg_getInt(arg6), 10);
|
|
stack_deinit(&s);
|
|
arg_deinit(arg4);
|
|
arg_deinit(arg5);
|
|
arg_deinit(arg6);
|
|
EXPECT_EQ(pikaMemNow(), 0);
|
|
}
|
|
|
|
TEST(stack, str) {
|
|
Stack s;
|
|
stack_init(&s);
|
|
stack_pushStr(&s, "abc");
|
|
stack_pushStr(&s, "123");
|
|
stack_pushStr(&s, "xyz");
|
|
char buff[32] = {0};
|
|
EXPECT_STREQ(stack_popStr(&s, buff), "xyz");
|
|
EXPECT_STREQ(stack_popStr(&s, buff), "123");
|
|
EXPECT_STREQ(stack_popStr(&s, buff), "abc");
|
|
stack_deinit(&s);
|
|
EXPECT_EQ(pikaMemNow(), 0);
|
|
}
|