testSerializationBase.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 
19 #include <gtsam/inference/Key.h>
20 
21 #include <gtsam/base/Matrix.h>
22 #include <gtsam/base/Vector.h>
23 #include <gtsam/base/FastList.h>
24 #include <gtsam/base/FastMap.h>
25 #include <gtsam/base/FastSet.h>
26 #include <gtsam/base/FastVector.h>
27 
30 
31 using namespace std;
32 using namespace gtsam;
33 using namespace gtsam::serializationTestHelpers;
34 
35 Vector v1 = Vector2(1.0, 2.0);
36 Vector v2 = Vector2(3.0, 4.0);
37 Vector v3 = Vector2(5.0, 6.0);
38 
39 /* ************************************************************************* */
40 TEST (Serialization, FastList) {
41  FastList<Vector> list;
42  list.push_back(v1);
43  list.push_back(v2);
44  list.push_back(v3);
45 
46  EXPECT(equality(list));
47  EXPECT(equalityXML(list));
48  EXPECT(equalityBinary(list));
49 }
50 
51 /* ************************************************************************* */
52 TEST (Serialization, FastMap) {
54  map.insert(make_pair(1, v1));
55  map.insert(make_pair(2, v2));
56  map.insert(make_pair(3, v3));
57 
58  EXPECT(equality(map));
59  EXPECT(equalityXML(map));
60  EXPECT(equalityBinary(map));
61 }
62 
63 /* ************************************************************************* */
64 TEST (Serialization, FastSet) {
65  KeySet set;
66  set.insert(1);
67  set.insert(2);
68  set.insert(3);
69 
70  EXPECT(equality(set));
71  EXPECT(equalityXML(set));
72  EXPECT(equalityBinary(set));
73 }
74 
75 /* ************************************************************************* */
76 TEST (Serialization, FastVector) {
77  FastVector<Vector> vector;
78  vector.push_back(v1);
79  vector.push_back(v2);
80  vector.push_back(v3);
81 
82  EXPECT(equality(vector));
83  EXPECT(equalityXML(vector));
84  EXPECT(equalityBinary(vector));
85 }
86 
87 /* ************************************************************************* */
88 TEST (Serialization, matrix_vector) {
89  EXPECT(equality<Vector>((Vector(4) << 1.0, 2.0, 3.0, 4.0).finished()));
90  EXPECT(equality<Vector2>(Vector2(1.0, 2.0)));
91  EXPECT(equality<Vector3>(Vector3(1.0, 2.0, 3.0)));
92  EXPECT(equality<Vector6>((Vector6() << 1.0, 2.0, 3.0, 4.0, 5.0, 6.0).finished()));
93  EXPECT(equality<Matrix>((Matrix(2, 2) << 1.0, 2.0, 3.0, 4.0).finished()));
94 
95  EXPECT(equalityXML<Vector>((Vector(4) << 1.0, 2.0, 3.0, 4.0).finished()));
96  EXPECT(equalityXML<Vector2>(Vector2(1.0, 2.0)));
97  EXPECT(equalityXML<Vector3>(Vector3(1.0, 2.0, 3.0)));
98  EXPECT(equalityXML<Vector6>((Vector6() << 1.0, 2.0, 3.0, 4.0, 5.0, 6.0).finished()));
99  EXPECT(equalityXML<Matrix>((Matrix(2, 2) << 1.0, 2.0, 3.0, 4.0).finished()));
100 
101  EXPECT(equalityBinary<Vector>((Vector(4) << 1.0, 2.0, 3.0, 4.0).finished()));
102  EXPECT(equalityBinary<Vector2>(Vector2(1.0, 2.0)));
103  EXPECT(equalityBinary<Vector3>(Vector3(1.0, 2.0, 3.0)));
104  EXPECT(equalityBinary<Vector6>((Vector6() << 1.0, 2.0, 3.0, 4.0, 5.0, 6.0).finished()));
105  EXPECT(equalityBinary<Matrix>((Matrix(2, 2) << 1.0, 2.0, 3.0, 4.0).finished()));
106 }
107 
108 /* ************************************************************************* */
109 
110 
111 /* ************************************************************************* */
112 int main() { TestResult tr; return TestRegistry::runAllTests(tr); }
113 /* ************************************************************************* */
A thin wrapper around std::list that uses boost&#39;s fast_pool_allocator.
Vector v2
static int runAllTests(TestResult &result)
Eigen::Vector3d Vector3
Definition: Vector.h:43
Vector v1
Definition: Half.h:150
Vector v3
Eigen::VectorXd Vector
Definition: Vector.h:38
TEST(Serialization, FastList)
#define EXPECT(condition)
Definition: Test.h:151
A thin wrapper around std::vector that uses a custom allocator.
traits
Definition: chartTesting.h:28
typedef and functions to augment Eigen&#39;s VectorXd
int main()
A thin wrapper around std::map that uses boost&#39;s fast_pool_allocator.
Eigen::Vector2d Vector2
Definition: Vector.h:42
std::vector< T, typename internal::FastDefaultVectorAllocator< T >::type > FastVector
Definition: FastVector.h:34
Eigen::Matrix< double, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor > Matrix
Eigen::Matrix< double, Eigen::Dynamic, 1 > Vector
A thin wrapper around std::set that uses boost&#39;s fast_pool_allocator.


gtsam
Author(s):
autogenerated on Sat May 8 2021 02:49:23