testHybridValues.cpp
Go to the documentation of this file.
1 /* ----------------------------------------------------------------------------
2 
3  * GTSAM Copyright 2010, Georgia Tech Research Corporation,
4  * Atlanta, Georgia 30332-0415
5  * All Rights Reserved
6  * Authors: Frank Dellaert, et al. (see THANKS for the full author list)
7 
8  * See LICENSE for the license information
9 
10  * -------------------------------------------------------------------------- */
11 
18 #include <gtsam/base/Testable.h>
24 #include <gtsam/inference/Key.h>
25 #include <gtsam/inference/Symbol.h>
27 #include <gtsam/nonlinear/Values.h>
28 
29 // Include for test suite
31 
32 using namespace std;
33 using namespace gtsam;
34 
35 static const HybridValues kExample{{{99, Vector2(2, 3)}}, {{100, 3}}};
36 
37 /* ************************************************************************* */
38 TEST(HybridValues, Basics) {
40  values.insert(99, Vector2(2, 3));
41  values.insert(100, 3);
43  EXPECT(assert_equal(values.at(99), Vector2(2, 3)));
44  EXPECT(assert_equal(values.atDiscrete(100), int(3)));
45 
46  HybridValues values2;
47  values2.insert(100, 3);
48  values2.insert(99, Vector2(2, 3));
49  EXPECT(assert_equal(kExample, values2));
50 }
51 
52 /* ************************************************************************* */
53 // Check insert
54 TEST(HybridValues, Insert) {
55  HybridValues actual;
56  EXPECT(assert_equal({{}, {{100, 3}}}, //
57  actual.insert(DiscreteValues{{100, 3}})));
59  actual.insert(VectorValues{{99, Vector2(2, 3)}})));
60  HybridValues actual2;
62 }
63 
64 /* ************************************************************************* */
65 // Check update.
66 TEST(HybridValues, Update) {
67  HybridValues actual(kExample);
68  EXPECT(assert_equal({{{99, Vector2(2, 3)}}, {{100, 2}}},
69  actual.update(DiscreteValues{{100, 2}})));
70  EXPECT(assert_equal({{{99, Vector1(4)}}, {{100, 2}}},
71  actual.update(VectorValues{{99, Vector1(4)}})));
72  HybridValues actual2(kExample);
74 }
75 
76 /* ************************************************************************* */
77 int main() {
78  TestResult tr;
79  return TestRegistry::runAllTests(tr);
80 }
81 /* ************************************************************************* */
TestRegistry::runAllTests
static int runAllTests(TestResult &result)
Definition: TestRegistry.cpp:27
gtsam::HybridValues
Definition: HybridValues.h:37
Testable.h
Concept check for values that can be used in unit tests.
EXPECT
#define EXPECT(condition)
Definition: Test.h:150
gtsam::Vector2
Eigen::Vector2d Vector2
Definition: Vector.h:42
TestHarness.h
gtsam::HybridValues::update
HybridValues & update(const VectorValues &values)
Definition: HybridValues.cpp:135
different_sigmas::values
HybridValues values
Definition: testHybridBayesNet.cpp:245
TestableAssertions.h
Provides additional testing facilities for common data structures.
Key.h
Vector1
Eigen::Matrix< double, 1, 1 > Vector1
Definition: testEvent.cpp:33
gtsam::VectorValues
Definition: VectorValues.h:74
Assignment.h
An assignment from labels to a discrete value index (size_t)
Symbol.h
gtsam::HybridValues::insert
void insert(Key j, const Vector &value)
Definition: HybridValues.cpp:85
Vector2
Definition: test_operator_overloading.cpp:18
VectorValues.h
Factor Graph Values.
TestResult
Definition: TestResult.h:26
DiscreteKey.h
specialized key for discrete variables
kExample
static const HybridValues kExample
Definition: testHybridValues.cpp:35
gtsam::HybridValues::at
Vector & at(Key j)
Definition: HybridValues.cpp:129
gtsam
traits
Definition: SFMdata.h:40
gtsam::HybridValues::atDiscrete
size_t & atDiscrete(Key j)
Definition: HybridValues.cpp:132
DiscreteValues.h
gtsam::DiscreteValues
Definition: DiscreteValues.h:34
std
Definition: BFloat16.h:88
gtsam::assert_equal
bool assert_equal(const Matrix &expected, const Matrix &actual, double tol)
Definition: Matrix.cpp:40
TEST
TEST(HybridValues, Basics)
Definition: testHybridValues.cpp:38
HybridValues.h
Values.h
A non-templated config holding any types of Manifold-group elements.
main
int main()
Definition: testHybridValues.cpp:77


gtsam
Author(s):
autogenerated on Sat Nov 16 2024 04:07:38