Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
za0612
pcl
提交
e24d1164
P
pcl
项目概览
za0612
/
pcl
与 Fork 源项目一致
从无法访问的项目Fork
通知
13
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
pcl
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
e24d1164
编写于
2月 06, 2020
作者:
K
Kunal Tyagi
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Adding tests for test to number parsers
上级
9e1435d6
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
192 addition
and
0 deletion
+192
-0
test/common/CMakeLists.txt
test/common/CMakeLists.txt
+1
-0
test/common/test_parse.cpp
test/common/test_parse.cpp
+191
-0
未找到文件。
test/common/CMakeLists.txt
浏览文件 @
e24d1164
...
...
@@ -17,6 +17,7 @@ PCL_ADD_TEST(common_test_wrappers test_wrappers FILES test_wrappers.cpp LINK_WIT
PCL_ADD_TEST
(
common_test_macros test_macros FILES test_macros.cpp LINK_WITH pcl_gtest pcl_common
)
PCL_ADD_TEST
(
common_vector_average test_vector_average FILES test_vector_average.cpp LINK_WITH pcl_gtest
)
PCL_ADD_TEST
(
common_common test_common FILES test_common.cpp LINK_WITH pcl_gtest pcl_common
)
PCL_ADD_TEST
(
common_parse test_parse FILES test_parse.cpp LINK_WITH pcl_gtest pcl_common
)
PCL_ADD_TEST
(
common_geometry test_geometry FILES test_geometry.cpp LINK_WITH pcl_gtest pcl_common
)
PCL_ADD_TEST
(
common_copy_point test_copy_point FILES test_copy_point.cpp LINK_WITH pcl_gtest pcl_common
)
PCL_ADD_TEST
(
common_transforms test_transforms FILES test_transforms.cpp LINK_WITH pcl_gtest pcl_common
)
...
...
test/common/test_parse.cpp
0 → 100644
浏览文件 @
e24d1164
/*
* Software License Agreement (BSD License)
*
* Point Cloud Library (PCL) - www.pointclouds.org
* Copyright (c) 2020-, Open Perception, Inc.
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of the copyright holder(s) nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
*/
#include <gtest/gtest.h>
#include <pcl/pcl_tests.h>
#include <pcl/console/parse.h>
using
namespace
std
;
///////////////////////////////////////////////////////////////////////////////////////////
TEST
(
PCL
,
parse_double
)
{
const
char
arg0
[]
=
{
"test_name"
};
const
char
arg1
[]
=
{
"double"
};
const
char
arg2_1
[]
=
{
"-3.14e+0"
};
const
char
arg2_2
[]
=
{
"-3.14f+0"
};
const
char
arg2_3
[]
=
{
"3.14e+309"
};
const
char
*
argv_1
[]
=
{
&
arg0
[
0
],
&
arg1
[
0
],
&
arg2_1
[
0
],
nullptr
};
const
char
*
argv_2
[]
=
{
&
arg0
[
0
],
&
arg1
[
0
],
&
arg2_2
[
0
],
nullptr
};
const
char
*
argv_3
[]
=
{
&
arg0
[
0
],
&
arg1
[
0
],
&
arg2_3
[
0
],
nullptr
};
const
int
argc
=
static_cast
<
int
>
(
sizeof
(
argv_1
)
/
sizeof
(
argv_1
[
0
]))
-
1
;
int
index
=
-
1
;
double
value
=
0
;
index
=
pcl
::
console
::
parse_argument
(
argc
,
argv_1
,
"double"
,
value
);
EXPECT_DOUBLE_EQ
(
-
3.14
,
value
);
EXPECT_EQ
(
1
,
index
);
index
=
pcl
::
console
::
parse_argument
(
argc
,
argv_2
,
"double"
,
value
);
EXPECT_EQ
(
-
1
,
index
);
index
=
pcl
::
console
::
parse_argument
(
argc
,
argv_3
,
"double"
,
value
);
EXPECT_EQ
(
-
1
,
index
);
}
///////////////////////////////////////////////////////////////////////////////////////////
TEST
(
PCL
,
parse_float
)
{
const
char
arg0
[]
=
{
"test_name"
};
const
char
arg1
[]
=
{
"float"
};
const
char
arg2_1
[]
=
{
"-3.14e+0"
};
const
char
arg2_2
[]
=
{
"-3.14f+0"
};
const
char
arg2_3
[]
=
{
"3.14e+39"
};
const
char
*
argv_1
[]
=
{
&
arg0
[
0
],
&
arg1
[
0
],
&
arg2_1
[
0
],
nullptr
};
const
char
*
argv_2
[]
=
{
&
arg0
[
0
],
&
arg1
[
0
],
&
arg2_2
[
0
],
nullptr
};
const
char
*
argv_3
[]
=
{
&
arg0
[
0
],
&
arg1
[
0
],
&
arg2_3
[
0
],
nullptr
};
const
int
argc
=
static_cast
<
int
>
(
sizeof
(
argv_1
)
/
sizeof
(
argv_1
[
0
]))
-
1
;
int
index
=
-
1
;
float
value
=
0
;
index
=
pcl
::
console
::
parse_argument
(
argc
,
argv_1
,
"float"
,
value
);
EXPECT_FLOAT_EQ
(
-
3.14
,
value
);
EXPECT_EQ
(
1
,
index
);
index
=
pcl
::
console
::
parse_argument
(
argc
,
argv_2
,
"float"
,
value
);
EXPECT_EQ
(
-
1
,
index
);
index
=
pcl
::
console
::
parse_argument
(
argc
,
argv_3
,
"float"
,
value
);
EXPECT_EQ
(
-
1
,
index
);
}
///////////////////////////////////////////////////////////////////////////////////////////
TEST
(
PCL
,
parse_longint
)
{
const
char
arg0
[]
=
{
"test_name"
};
const
char
arg1
[]
=
{
"long_int"
};
const
char
arg2_1
[]
=
{
"-314"
};
const
char
arg2_2
[]
=
{
"3.14"
};
const
char
arg2_3
[]
=
{
"18446744073709551615"
};
const
char
*
argv_1
[]
=
{
&
arg0
[
0
],
&
arg1
[
0
],
&
arg2_1
[
0
],
nullptr
};
const
char
*
argv_2
[]
=
{
&
arg0
[
0
],
&
arg1
[
0
],
&
arg2_2
[
0
],
nullptr
};
const
char
*
argv_3
[]
=
{
&
arg0
[
0
],
&
arg1
[
0
],
&
arg2_3
[
0
],
nullptr
};
const
int
argc
=
static_cast
<
int
>
(
sizeof
(
argv_1
)
/
sizeof
(
argv_1
[
0
]))
-
1
;
int
index
=
-
1
;
long
int
value
=
0
;
index
=
pcl
::
console
::
parse_argument
(
argc
,
argv_1
,
"long_int"
,
value
);
EXPECT_EQ
(
-
314
,
value
);
EXPECT_EQ
(
1
,
index
);
index
=
pcl
::
console
::
parse_argument
(
argc
,
argv_2
,
"long_int"
,
value
);
EXPECT_EQ
(
-
1
,
index
);
index
=
pcl
::
console
::
parse_argument
(
argc
,
argv_3
,
"long_int"
,
value
);
EXPECT_EQ
(
-
1
,
index
);
}
///////////////////////////////////////////////////////////////////////////////////////////
TEST
(
PCL
,
parse_unsignedint
)
{
const
char
arg0
[]
=
{
"test_name"
};
const
char
arg1
[]
=
{
"unsigned_int"
};
const
char
arg2_1
[]
=
{
"314"
};
const
char
arg2_2
[]
=
{
"-314"
};
const
char
arg2_3
[]
=
{
"18446744073709551615"
};
const
char
*
argv_1
[]
=
{
&
arg0
[
0
],
&
arg1
[
0
],
&
arg2_1
[
0
],
nullptr
};
const
char
*
argv_2
[]
=
{
&
arg0
[
0
],
&
arg1
[
0
],
&
arg2_2
[
0
],
nullptr
};
const
char
*
argv_3
[]
=
{
&
arg0
[
0
],
&
arg1
[
0
],
&
arg2_3
[
0
],
nullptr
};
const
int
argc
=
static_cast
<
int
>
(
sizeof
(
argv_1
)
/
sizeof
(
argv_1
[
0
]))
-
1
;
int
index
=
-
1
;
unsigned
int
value
=
53
;
index
=
pcl
::
console
::
parse_argument
(
argc
,
argv_1
,
"unsigned_int"
,
value
);
EXPECT_EQ
(
314
,
value
);
EXPECT_EQ
(
1
,
index
);
index
=
pcl
::
console
::
parse_argument
(
argc
,
argv_2
,
"unsigned_int"
,
value
);
EXPECT_EQ
(
-
1
,
index
);
index
=
pcl
::
console
::
parse_argument
(
argc
,
argv_3
,
"unsigned_int"
,
value
);
EXPECT_EQ
(
-
1
,
index
);
}
///////////////////////////////////////////////////////////////////////////////////////////
TEST
(
PCL
,
parse_int
)
{
const
char
arg0
[]
=
{
"test_name"
};
const
char
arg1
[]
=
{
"int"
};
const
char
arg2_1
[]
=
{
"-314"
};
const
char
arg2_2
[]
=
{
"3.14"
};
const
char
arg2_3
[]
=
{
"18446744073709551615"
};
const
char
*
argv_1
[]
=
{
&
arg0
[
0
],
&
arg1
[
0
],
&
arg2_1
[
0
],
nullptr
};
const
char
*
argv_2
[]
=
{
&
arg0
[
0
],
&
arg1
[
0
],
&
arg2_2
[
0
],
nullptr
};
const
char
*
argv_3
[]
=
{
&
arg0
[
0
],
&
arg1
[
0
],
&
arg2_3
[
0
],
nullptr
};
const
int
argc
=
static_cast
<
int
>
(
sizeof
(
argv_1
)
/
sizeof
(
argv_1
[
0
]))
-
1
;
int
index
=
-
1
;
int
value
=
0
;
index
=
pcl
::
console
::
parse_argument
(
argc
,
argv_1
,
"int"
,
value
);
EXPECT_EQ
(
-
314
,
value
);
EXPECT_EQ
(
1
,
index
);
index
=
pcl
::
console
::
parse_argument
(
argc
,
argv_2
,
"int"
,
value
);
EXPECT_EQ
(
-
1
,
index
);
index
=
pcl
::
console
::
parse_argument
(
argc
,
argv_3
,
"int"
,
value
);
EXPECT_EQ
(
-
1
,
index
);
}
/* ---[ */
int
main
(
int
argc
,
char
**
argv
)
{
testing
::
InitGoogleTest
(
&
argc
,
argv
);
return
(
RUN_ALL_TESTS
());
}
/* ]--- */
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录