Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Pinoxchio
apollo
提交
00e30332
A
apollo
项目概览
Pinoxchio
/
apollo
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
A
apollo
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
00e30332
编写于
8月 02, 2017
作者:
C
Calvin Miao
提交者:
Kecheng Xu
8月 02, 2017
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Added road graph unit test
上级
8e5fa45d
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
157 addition
and
0 deletion
+157
-0
modules/prediction/common/BUILD
modules/prediction/common/BUILD
+17
-0
modules/prediction/common/road_graph_test.cc
modules/prediction/common/road_graph_test.cc
+140
-0
未找到文件。
modules/prediction/common/BUILD
浏览文件 @
00e30332
...
...
@@ -48,4 +48,21 @@ cc_library(
],
)
cc_test
(
name
=
"road_graph_test"
,
size
=
"small"
,
srcs
=
[
"road_graph_test.cc"
],
data
=
[
"//modules/prediction:prediction_data"
,
"//modules/prediction:prediction_testdata"
,
],
deps
=
[
"//modules/prediction/common:road_graph"
,
"//modules/prediction/common:prediction_gflags"
,
"//modules/prediction/common:prediction_map"
,
"//modules/common/math:math_utils"
,
"@gtest//:main"
,
]
)
cpplint
()
modules/prediction/common/road_graph_test.cc
0 → 100644
浏览文件 @
00e30332
/******************************************************************************
* Copyright 2017 The Apollo Authors. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*****************************************************************************/
#include "modules/prediction/common/road_graph.h"
#include <string>
#include "gtest/gtest.h"
#include "modules/prediction/common/prediction_gflags.h"
#include "modules/prediction/common/prediction_map.h"
#include "modules/prediction/proto/lane_graph.pb.h"
#include "modules/common/math/math_utils.h"
namespace
apollo
{
namespace
prediction
{
using
::
apollo
::
common
::
ErrorCode
;
class
RoadGraphTest
:
public
::
testing
::
Test
{
public:
virtual
void
SetUp
()
{
FLAGS_map_file
=
"modules/prediction/testdata/kml_map.bin"
;
map_
=
PredictionMap
::
instance
();
}
protected:
PredictionMap
*
map_
;
};
TEST_F
(
RoadGraphTest
,
General
)
{
auto
lane
=
map_
->
LaneById
(
"l9"
);
EXPECT_TRUE
(
lane
!=
nullptr
);
double
start_s
=
99.0
;
double
length
=
100.0
;
RoadGraph
road_graph
(
start_s
,
length
,
lane
);
LaneGraph
lane_graph
;
EXPECT_EQ
(
road_graph
.
BuildLaneGraph
(
&
lane_graph
),
ErrorCode
::
OK
);
EXPECT_EQ
(
1
,
lane_graph
.
lane_sequence_size
());
EXPECT_EQ
(
3
,
lane_graph
.
lane_sequence
(
0
).
lane_segment_size
());
EXPECT_EQ
(
"l9"
,
lane_graph
.
lane_sequence
(
0
).
lane_segment
(
0
).
lane_id
());
EXPECT_EQ
(
"l18"
,
lane_graph
.
lane_sequence
(
0
).
lane_segment
(
1
).
lane_id
());
EXPECT_EQ
(
"l21"
,
lane_graph
.
lane_sequence
(
0
).
lane_segment
(
2
).
lane_id
());
for
(
const
auto
&
lane_sequence
:
lane_graph
.
lane_sequence
())
{
double
total_length
=
0.0
;
for
(
const
auto
&
lane_segment
:
lane_sequence
.
lane_segment
())
{
total_length
+=
(
lane_segment
.
end_s
()
-
lane_segment
.
start_s
());
}
EXPECT_DOUBLE_EQ
(
length
,
total_length
);
}
}
TEST_F
(
RoadGraphTest
,
NegativeStartS
)
{
auto
lane
=
map_
->
LaneById
(
"l9"
);
EXPECT_TRUE
(
lane
!=
nullptr
);
double
start_s
=
-
10.0
;
double
length
=
50.0
;
RoadGraph
road_graph
(
start_s
,
length
,
lane
);
LaneGraph
lane_graph
;
EXPECT_EQ
(
road_graph
.
BuildLaneGraph
(
&
lane_graph
),
ErrorCode
::
OK
);
EXPECT_EQ
(
1
,
lane_graph
.
lane_sequence_size
());
EXPECT_EQ
(
1
,
lane_graph
.
lane_sequence
(
0
).
lane_segment_size
());
EXPECT_EQ
(
"l9"
,
lane_graph
.
lane_sequence
(
0
).
lane_segment
(
0
).
lane_id
());
for
(
const
auto
&
lane_sequence
:
lane_graph
.
lane_sequence
())
{
double
total_length
=
0.0
;
for
(
const
auto
&
lane_segment
:
lane_sequence
.
lane_segment
())
{
total_length
+=
(
lane_segment
.
end_s
()
-
lane_segment
.
start_s
());
}
EXPECT_DOUBLE_EQ
(
length
,
total_length
);
}
}
TEST_F
(
RoadGraphTest
,
LengthLongerThanEnd
)
{
auto
lane
=
map_
->
LaneById
(
"l22"
);
EXPECT_TRUE
(
lane
!=
nullptr
);
double
start_s
=
200.0
;
double
length
=
200.0
;
RoadGraph
road_graph
(
start_s
,
length
,
lane
);
LaneGraph
lane_graph
;
EXPECT_EQ
(
road_graph
.
BuildLaneGraph
(
&
lane_graph
),
ErrorCode
::
OK
);
EXPECT_EQ
(
1
,
lane_graph
.
lane_sequence_size
());
EXPECT_EQ
(
3
,
lane_graph
.
lane_sequence
(
0
).
lane_segment_size
());
EXPECT_EQ
(
"l22"
,
lane_graph
.
lane_sequence
(
0
).
lane_segment
(
0
).
lane_id
());
EXPECT_EQ
(
"l100"
,
lane_graph
.
lane_sequence
(
0
).
lane_segment
(
1
).
lane_id
());
EXPECT_EQ
(
"l97"
,
lane_graph
.
lane_sequence
(
0
).
lane_segment
(
2
).
lane_id
());
for
(
const
auto
&
lane_sequence
:
lane_graph
.
lane_sequence
())
{
double
total_length
=
0.0
;
for
(
const
auto
&
lane_segment
:
lane_sequence
.
lane_segment
())
{
total_length
+=
(
lane_segment
.
end_s
()
-
lane_segment
.
start_s
());
}
EXPECT_TRUE
(
::
apollo
::
common
::
math
::
DoubleCompare
(
total_length
,
length
)
<
0
);
}
}
TEST_F
(
RoadGraphTest
,
MultipleLaneSequence
)
{
auto
lane
=
map_
->
LaneById
(
"l20"
);
EXPECT_TRUE
(
lane
!=
nullptr
);
double
start_s
=
200.0
;
double
length
=
200.0
;
RoadGraph
road_graph
(
start_s
,
length
,
lane
);
LaneGraph
lane_graph
;
EXPECT_EQ
(
road_graph
.
BuildLaneGraph
(
&
lane_graph
),
ErrorCode
::
OK
);
EXPECT_EQ
(
2
,
lane_graph
.
lane_sequence_size
());
EXPECT_EQ
(
3
,
lane_graph
.
lane_sequence
(
0
).
lane_segment_size
());
EXPECT_EQ
(
3
,
lane_graph
.
lane_sequence
(
1
).
lane_segment_size
());
EXPECT_EQ
(
"l20"
,
lane_graph
.
lane_sequence
(
0
).
lane_segment
(
0
).
lane_id
());
EXPECT_EQ
(
"l31"
,
lane_graph
.
lane_sequence
(
0
).
lane_segment
(
1
).
lane_id
());
EXPECT_EQ
(
"l29"
,
lane_graph
.
lane_sequence
(
0
).
lane_segment
(
2
).
lane_id
());
EXPECT_EQ
(
"l20"
,
lane_graph
.
lane_sequence
(
1
).
lane_segment
(
0
).
lane_id
());
EXPECT_EQ
(
"l98"
,
lane_graph
.
lane_sequence
(
1
).
lane_segment
(
1
).
lane_id
());
EXPECT_EQ
(
"l95"
,
lane_graph
.
lane_sequence
(
1
).
lane_segment
(
2
).
lane_id
());
}
}
// namespace prediction
}
// namespace apollo
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录