Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
wolf
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mobile_robotics
wolf_projects
wolf_lib
wolf
Commits
48482444
Commit
48482444
authored
5 years ago
by
Joan Solà Ortega
Browse files
Options
Downloads
Patches
Plain Diff
Add gtest for constructor with lists
parent
3ba91db0
No related branches found
No related tags found
1 merge request
!346
Resolve "Frame/Capture/Feature/Landmark Other as list/vectors in FactorBase"
Pipeline
#5081
passed
5 years ago
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
test/CMakeLists.txt
+7
-7
7 additions, 7 deletions
test/CMakeLists.txt
test/gtest_factor_base.cpp
+120
-0
120 additions, 0 deletions
test/gtest_factor_base.cpp
with
127 additions
and
7 deletions
test/CMakeLists.txt
+
7
−
7
View file @
48482444
...
@@ -47,13 +47,9 @@ add_library(dummy ${SRC_DUMMY})
...
@@ -47,13 +47,9 @@ add_library(dummy ${SRC_DUMMY})
wolf_add_gtest
(
gtest_capture_base gtest_capture_base.cpp
)
wolf_add_gtest
(
gtest_capture_base gtest_capture_base.cpp
)
target_link_libraries
(
gtest_capture_base
${
PROJECT_NAME
}
)
target_link_libraries
(
gtest_capture_base
${
PROJECT_NAME
}
)
# CaptureBase class test
# FactorBase class test
#wolf_add_gtest(gtest_factor_sparse gtest_factor_sparse.cpp)
wolf_add_gtest
(
gtest_factor_base gtest_factor_base.cpp
)
#target_link_libraries(gtest_factor_sparse ${PROJECT_NAME})
target_link_libraries
(
gtest_factor_base
${
PROJECT_NAME
}
)
# FactorBlockDifference class test
wolf_add_gtest
(
gtest_factor_block_difference gtest_factor_block_difference.cpp
)
target_link_libraries
(
gtest_factor_block_difference
${
PROJECT_NAME
}
)
# FactorAutodiff class test
# FactorAutodiff class test
wolf_add_gtest
(
gtest_factor_autodiff gtest_factor_autodiff.cpp
)
wolf_add_gtest
(
gtest_factor_autodiff gtest_factor_autodiff.cpp
)
...
@@ -169,6 +165,10 @@ target_link_libraries(gtest_factor_absolute ${PROJECT_NAME})
...
@@ -169,6 +165,10 @@ target_link_libraries(gtest_factor_absolute ${PROJECT_NAME})
wolf_add_gtest
(
gtest_factor_autodiff_distance_3d gtest_factor_autodiff_distance_3d.cpp
)
wolf_add_gtest
(
gtest_factor_autodiff_distance_3d gtest_factor_autodiff_distance_3d.cpp
)
target_link_libraries
(
gtest_factor_autodiff_distance_3d
${
PROJECT_NAME
}
)
target_link_libraries
(
gtest_factor_autodiff_distance_3d
${
PROJECT_NAME
}
)
# FactorBlockDifference class test
wolf_add_gtest
(
gtest_factor_block_difference gtest_factor_block_difference.cpp
)
target_link_libraries
(
gtest_factor_block_difference
${
PROJECT_NAME
}
)
# FactorOdom3d class test
# FactorOdom3d class test
wolf_add_gtest
(
gtest_factor_diff_drive gtest_factor_diff_drive.cpp
)
wolf_add_gtest
(
gtest_factor_diff_drive gtest_factor_diff_drive.cpp
)
target_link_libraries
(
gtest_factor_diff_drive
${
PROJECT_NAME
}
)
target_link_libraries
(
gtest_factor_diff_drive
${
PROJECT_NAME
}
)
...
...
This diff is collapsed.
Click to expand it.
test/gtest_factor_base.cpp
0 → 100644
+
120
−
0
View file @
48482444
/*
* gtest_factor_base.cpp
*
* Created on: Apr 2, 2020
* Author: jsola
*/
#include
"core/utils/utils_gtest.h"
#include
"core/utils/logging.h"
#include
"core/factor/factor_base.h"
using
namespace
wolf
;
using
namespace
Eigen
;
class
FactorBaseTest
:
public
testing
::
Test
{
public:
FrameBasePtr
F0
,
F1
;
CaptureBasePtr
C0
,
C1
;
FeatureBasePtr
f0
,
f1
;
LandmarkBasePtr
L0
,
L1
;
virtual
void
SetUp
()
{
F0
=
std
::
make_shared
<
FrameBase
>
(
0.0
,
nullptr
);
F1
=
std
::
make_shared
<
FrameBase
>
(
1.0
,
nullptr
);
C0
=
std
::
make_shared
<
CaptureBase
>
(
"Capture"
,
0.0
,
nullptr
);
C1
=
std
::
make_shared
<
CaptureBase
>
(
"Capture"
,
1.0
,
nullptr
);
f0
=
std
::
make_shared
<
FeatureBase
>
(
"Feature"
,
Vector2d
(
1
,
2
),
Matrix2d
::
Identity
(),
FeatureBase
::
UncertaintyType
::
UNCERTAINTY_IS_COVARIANCE
);
f1
=
std
::
make_shared
<
FeatureBase
>
(
"Feature"
,
Vector2d
(
1
,
2
),
Matrix2d
::
Identity
(),
FeatureBase
::
UncertaintyType
::
UNCERTAINTY_IS_COVARIANCE
);
L0
=
std
::
make_shared
<
LandmarkBase
>
(
"Lmk"
,
nullptr
);
L1
=
std
::
make_shared
<
LandmarkBase
>
(
"Lmk"
,
nullptr
);
}
// virtual void TearDown(){}
};
class
FactorDummy
:
public
FactorBase
{
public:
FactorDummy
(
const
FrameBasePtr
&
_frame_other
,
const
CaptureBasePtr
&
_capture_other
,
const
FeatureBasePtr
&
_feature_other
,
const
LandmarkBasePtr
&
_landmark_other
)
:
FactorBase
(
"Dummy"
,
_frame_other
,
_capture_other
,
_feature_other
,
_landmark_other
,
nullptr
,
false
)
{
//
}
FactorDummy
(
const
FrameBasePtrList
&
_frame_other_list
,
const
CaptureBasePtrList
&
_capture_other_list
,
const
FeatureBasePtrList
&
_feature_other_list
,
const
LandmarkBasePtrList
&
_landmark_other_list
)
:
FactorBase
(
"Dummy"
,
_frame_other_list
,
_capture_other_list
,
_feature_other_list
,
_landmark_other_list
,
nullptr
,
false
)
{
//
}
virtual
~
FactorDummy
()
=
default
;
virtual
std
::
string
getTopology
()
const
override
{
return
"DUMMY"
;}
virtual
bool
evaluate
(
double
const
*
const
*
_parameters
,
double
*
_residuals
,
double
**
_jacobians
)
const
override
{
return
true
;}
virtual
void
evaluate
(
const
std
::
vector
<
const
double
*>&
_states_ptr
,
Eigen
::
VectorXd
&
_residual
,
std
::
vector
<
Eigen
::
MatrixXd
>&
_jacobians
)
const
override
{}
virtual
JacobianMethod
getJacobianMethod
()
const
override
{
return
JacobianMethod
::
JAC_ANALYTIC
;}
virtual
std
::
vector
<
StateBlockPtr
>
getStateBlockPtrVector
()
const
override
{
std
::
vector
<
StateBlockPtr
>
v
;
return
v
;}
virtual
std
::
vector
<
unsigned
int
>
getStateSizes
()
const
override
{
std
::
vector
<
unsigned
int
>
v
;
return
v
;}
virtual
unsigned
int
getSize
()
const
override
{
return
0
;}
};
TEST_F
(
FactorBaseTest
,
constructor_from_pointers
)
{
FactorDummy
fac
(
nullptr
,
C0
,
f0
,
nullptr
);
ASSERT_TRUE
(
fac
.
getFrameOtherList
().
empty
());
ASSERT_EQ
(
fac
.
getCaptureOtherList
().
size
(),
1
);
ASSERT_EQ
(
fac
.
getFeatureOtherList
().
size
(),
1
);
ASSERT_TRUE
(
fac
.
getLandmarkOtherList
().
empty
());
}
TEST_F
(
FactorBaseTest
,
constructor_from_lists
)
{
FactorDummy
fac
({},{
C0
},{
f0
,
f1
},{});
ASSERT_TRUE
(
fac
.
getFrameOtherList
().
empty
());
ASSERT_EQ
(
fac
.
getCaptureOtherList
().
size
(),
1
);
ASSERT_EQ
(
fac
.
getFeatureOtherList
().
size
(),
2
);
ASSERT_TRUE
(
fac
.
getLandmarkOtherList
().
empty
());
}
int
main
(
int
argc
,
char
**
argv
)
{
testing
::
InitGoogleTest
(
&
argc
,
argv
);
// restrict to a group of tests only
//::testing::GTEST_FLAG(filter) = "TestInit.*";
// restrict to this test only
//::testing::GTEST_FLAG(filter) = "TestInit.testName";
return
RUN_ALL_TESTS
();
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment