debuging args

This commit is contained in:
lyon tab s7 2021-08-21 21:52:54 +08:00
parent 50023da3aa
commit 9b700cbe47
3 changed files with 52 additions and 2 deletions

@ -1 +1 @@
Subproject commit 2188f240790522bf50a5e7788b5d40e66c126c4f
Subproject commit 8b2428ce8189107eef2aa4871992c40e50e39f50

49
src/test/arg-test.cpp Normal file
View File

@ -0,0 +1,49 @@
#include "gtest/gtest.h"
extern "C"
{
#include "dataArg.h"
#include "dataString.h"
}
static int mem;
extern DMEM_STATE DMEMS;
TEST(arg_test, int_)
{
Arg *arg = New_arg(NULL);
arg_setInt(arg, 1);
int a = arg_getInt(arg);
EXPECT_EQ(a, 1);
arg_deinit(arg);
EXPECT_EQ(DMEMS.heapUsed, 0);
}
TEST(arg_test, float_)
{
Arg *arg = New_arg(NULL);
arg_setFloat(arg, 1.01);
float a = arg_getFloat(arg);
EXPECT_EQ(a, (float)1.01);
arg_deinit(arg);
EXPECT_EQ(DMEMS.heapUsed, 0);
}
TEST(arg_test, str_)
{
Arg *arg = New_arg(NULL);
arg_setStr(arg, (char *)"test str");
char *a = arg_getStr(arg);
EXPECT_EQ(strEqu(a, (char *)"test str"), 1);
arg_deinit(arg);
EXPECT_EQ(DMEMS.heapUsed, 0);
}
TEST(arg_test, ptr)
{
Arg *arg = New_arg(NULL);
int a = 1;
arg_setPtr(arg, &a);
int *pa = (int *)arg_getPtr(arg);
EXPECT_EQ(*pa, 1);
arg_deinit(arg);
EXPECT_EQ(DMEMS.heapUsed, 0);
}

3
test
View File

@ -1,3 +1,4 @@
rm build/src/test/pikascript_test
sh make.sh
build/src/test/pikascript_test
#build/src/test/pikascript_test
build/src/test/pikascript_test --gtest_filter=args_*