cancel arg->mem

This commit is contained in:
lyon 2021-08-31 23:30:57 +08:00
parent e675e4cc7b
commit 5bb9192f6a
4 changed files with 11 additions and 11 deletions

2
.vscode/launch.json vendored
View File

@ -10,7 +10,7 @@
"request": "launch",
"program": "${workspaceFolder}/build/src/test/pikascript_test",
"args": [
"--gtest_filter=args*"
"--gtest_filter=args.test3"
],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",

View File

@ -85,21 +85,21 @@ int32_t main()
}
{
Arg *arg = New_arg(NULL);
arg_setInt(arg, 0);
arg = arg_setInt(arg, 0);
checker_printMemUsage("int arg");
arg_deinit(arg);
checker_assertMemFree();
}
{
Arg *arg = New_arg(NULL);
arg_setFloat(arg, 0);
arg = arg_setFloat(arg, 0);
checker_printMemUsage("float arg");
arg_deinit(arg);
checker_assertMemFree();
}
{
Arg *arg = New_arg(NULL);
arg_setStr(arg, "test string");
arg = arg_setStr(arg, "test string");
checker_printMemUsage("str arg");
arg_deinit(arg);
checker_assertMemFree();

@ -1 +1 @@
Subproject commit 8d16db27496203dd3874ce1d7fc1a559b540a87d
Subproject commit 3aa6cd1631167a50e8957f11b6aa9ecc129a0979

View File

@ -9,7 +9,7 @@ static int mem;
TEST(arg_test, int_)
{
Arg *arg = New_arg(NULL);
arg_setInt(arg, 1);
arg = arg_setInt(arg, 1);
int a = arg_getInt(arg);
EXPECT_EQ(a, 1);
arg_deinit(arg);
@ -19,7 +19,7 @@ TEST(arg_test, int_)
TEST(arg_test, float_)
{
Arg *arg = New_arg(NULL);
arg_setFloat(arg, 1.01);
arg = arg_setFloat(arg, 1.01);
float a = arg_getFloat(arg);
EXPECT_EQ(a, (float)1.01);
arg_deinit(arg);
@ -29,7 +29,7 @@ TEST(arg_test, float_)
TEST(arg_test, str_)
{
Arg *arg = New_arg(NULL);
arg_setStr(arg, (char *)"test str");
arg = arg_setStr(arg, (char *)"test str");
char *a = arg_getStr(arg);
EXPECT_EQ(strEqu(a, (char *)"test str"), 1);
arg_deinit(arg);
@ -40,7 +40,7 @@ TEST(arg_test, ptr)
{
Arg *arg = New_arg(NULL);
int a = 1;
arg_setPtr(arg, &a);
arg = arg_setPtr(arg, &a);
int *pa = (int *)arg_getPtr(arg);
EXPECT_EQ(*pa, 1);
arg_deinit(arg);
@ -50,7 +50,7 @@ TEST(arg_test, ptr)
TEST(arg_test, name)
{
Arg *arg = New_arg(NULL);
arg_setName(arg, (char *)"test");
arg = arg_setName(arg, (char *)"test");
char *name = arg_getName(arg);
EXPECT_STREQ((char *)"test", name);
arg_deinit(arg);
@ -60,7 +60,7 @@ TEST(arg_test, name)
TEST(arg_test, type)
{
Arg *arg = New_arg(NULL);
arg_setType(arg, (char *)"test");
arg = arg_setType(arg, (char *)"test");
char *type = arg_getType(arg);
EXPECT_EQ(1, strEqu((char *)"test", type));
arg_deinit(arg);