mirror of
https://gitee.com/Lyon1998/pikapython.git
synced 2025-01-29 17:22:56 +08:00
auto convert int args and flot args
This commit is contained in:
parent
717861f2a0
commit
b54cd1ed5a
0
port/linux/api-make-linux.sh
Normal file → Executable file
0
port/linux/api-make-linux.sh
Normal file → Executable file
0
port/linux/api-make-win10.sh
Normal file → Executable file
0
port/linux/api-make-win10.sh
Normal file → Executable file
0
port/linux/api-make.sh
Normal file → Executable file
0
port/linux/api-make.sh
Normal file → Executable file
0
port/linux/ci_benchmark.sh
Normal file → Executable file
0
port/linux/ci_benchmark.sh
Normal file → Executable file
0
port/linux/gtest.sh
Normal file → Executable file
0
port/linux/gtest.sh
Normal file → Executable file
0
port/linux/init.sh
Normal file → Executable file
0
port/linux/init.sh
Normal file → Executable file
0
port/linux/install_dependency.sh
Normal file → Executable file
0
port/linux/install_dependency.sh
Normal file → Executable file
0
port/linux/make.sh
Normal file → Executable file
0
port/linux/make.sh
Normal file → Executable file
0
port/linux/pkg-push.sh
Normal file → Executable file
0
port/linux/pkg-push.sh
Normal file → Executable file
0
port/linux/pull-core.sh
Normal file → Executable file
0
port/linux/pull-core.sh
Normal file → Executable file
0
port/linux/push-core.sh
Normal file → Executable file
0
port/linux/push-core.sh
Normal file → Executable file
0
port/linux/run.sh
Normal file → Executable file
0
port/linux/run.sh
Normal file → Executable file
0
port/linux/test-banchmark.sh
Normal file → Executable file
0
port/linux/test-banchmark.sh
Normal file → Executable file
@ -180,3 +180,18 @@ TEST(args, index) {
|
||||
args_deinit(args);
|
||||
EXPECT_EQ(pikaMemNow(), 0);
|
||||
}
|
||||
|
||||
TEST(args, int_float_convert) {
|
||||
Args* args = New_args(NULL);
|
||||
args_setInt(args, (char*)"a", 10);
|
||||
args_setFloat(args, (char*)"b", 2.333);
|
||||
|
||||
float a = args_getFloat(args, (char*)"a");
|
||||
int b = args_getInt(args, (char*)"b");
|
||||
/* assert */
|
||||
EXPECT_EQ(a, 10);
|
||||
EXPECT_FLOAT_EQ(b, 2);
|
||||
/* check memory */
|
||||
args_deinit(args);
|
||||
EXPECT_EQ(pikaMemNow(), 0);
|
||||
}
|
@ -284,7 +284,7 @@ TEST(pikaMain, PikaStdData) {
|
||||
int b = obj_getInt(pikaMain, (char*)"b");
|
||||
/* assert */
|
||||
EXPECT_EQ(a, 1);
|
||||
EXPECT_EQ(b, 0);
|
||||
EXPECT_EQ(b, -999999999);
|
||||
|
||||
/* deinit */
|
||||
obj_deinit(pikaMain);
|
||||
|
0
port/linux/update-compiler.sh
Normal file → Executable file
0
port/linux/update-compiler.sh
Normal file → Executable file
@ -108,7 +108,13 @@ int64_t args_getInt(Args* self, char* name) {
|
||||
if (NULL == arg) {
|
||||
return -999999999;
|
||||
}
|
||||
ArgType arg_type = arg_getType(arg);
|
||||
if (arg_type == TYPE_INT) {
|
||||
return arg_getInt(arg);
|
||||
} else if (arg_type == TYPE_FLOAT) {
|
||||
return (int)arg_getFloat(arg);
|
||||
}
|
||||
return -999999999;
|
||||
}
|
||||
|
||||
int32_t args_getSize(Args* self) {
|
||||
@ -129,7 +135,13 @@ float args_getFloat(Args* self, char* name) {
|
||||
if (NULL == arg) {
|
||||
return -999999999.0;
|
||||
}
|
||||
ArgType arg_type = arg_getType(arg);
|
||||
if (arg_type == TYPE_FLOAT) {
|
||||
return arg_getFloat(arg);
|
||||
} else if (arg_type == TYPE_INT) {
|
||||
return (float)arg_getInt(arg);
|
||||
}
|
||||
return -999999999.0;
|
||||
}
|
||||
|
||||
int32_t args_copyArg(Args* self, Arg* argToBeCopy) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user