From 9b700cbe474c2a2da64030266f2f2c48b221568e Mon Sep 17 00:00:00 2001 From: lyon tab s7 <645275593@qq.com> Date: Sat, 21 Aug 2021 21:52:54 +0800 Subject: [PATCH] debuging args --- src/package/pikascript-core | 2 +- src/test/arg-test.cpp | 49 +++++++++++++++++++++++++++++++++++++ test | 3 ++- 3 files changed, 52 insertions(+), 2 deletions(-) create mode 100644 src/test/arg-test.cpp diff --git a/src/package/pikascript-core b/src/package/pikascript-core index 2188f2407..8b2428ce8 160000 --- a/src/package/pikascript-core +++ b/src/package/pikascript-core @@ -1 +1 @@ -Subproject commit 2188f240790522bf50a5e7788b5d40e66c126c4f +Subproject commit 8b2428ce8189107eef2aa4871992c40e50e39f50 diff --git a/src/test/arg-test.cpp b/src/test/arg-test.cpp new file mode 100644 index 000000000..d047e5a36 --- /dev/null +++ b/src/test/arg-test.cpp @@ -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); +} diff --git a/test b/test index a2b4e86ef..d3a43c784 100644 --- a/test +++ b/test @@ -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_*