test_sophus_printers.cpp
Go to the documentation of this file.
1 // Copyright 2024 Ekumen, Inc.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #include <gtest/gtest.h>
16 
17 #include <sstream>
18 
19 #include <Eigen/Core>
20 
23 
24 namespace {
25 
26 TEST(SophusPrinters, Matrix1i) {
27  std::stringstream out;
28  out << Eigen::Matrix<int, 1, 1>{42};
29  ASSERT_EQ(out.str(), "(42)");
30 }
31 
32 TEST(SophusPrinters, Vector3d) {
33  std::stringstream out;
34  out << Eigen::Vector3d{1.5, 2.5, 3.5};
35  ASSERT_EQ(out.str(), "(1.5, 2.5, 3.5)");
36 }
37 
38 TEST(SophusPrinters, Matrix2d) {
39  std::stringstream out;
40  out << testing::as<Eigen::Matrix2d>({{1.0, 2.0}, {3.0, 4.0}});
41  ASSERT_EQ(out.str(), "(1, 2, 3, 4)");
42 }
43 
44 TEST(SophusPrinters, Matrix3i) {
45  std::stringstream out;
46  out << testing::as<Eigen::Matrix3i>({{9, 8, 7}, {6, 5, 4}, {3, 2, 1}});
47  ASSERT_EQ(out.str(), "(9, 8, 7, 6, 5, 4, 3, 2, 1)");
48 }
49 
50 TEST(SophusPrinters, SO2dOneZero) {
51  std::stringstream out;
52  out << Sophus::SO2d{0.0};
53  ASSERT_EQ(out.str(), "(1, 0)");
54 }
55 
56 TEST(SophusPrinters, SO2dZeroOne) {
57  std::stringstream out;
58  out << Sophus::SO2d{0.0, 1.0};
59  ASSERT_EQ(out.str(), "(0, 1)");
60 }
61 
62 TEST(SophusPrinters, SE2dTwoThree) {
63  std::stringstream out;
64  out << Sophus::SE2d{Sophus::SO2d{0.0}, Sophus::Vector2d{2.0, 3.0}};
65  ASSERT_EQ(out.str(), "((1, 0), (2, 3))");
66 }
67 
68 TEST(SophusPrinters, SE2dThreeTwo) {
69  std::stringstream out;
70  out << Sophus::SE2d{Sophus::SO2d{0.0, 1.0}, Sophus::Vector2d{3.0, 2.0}};
71  ASSERT_EQ(out.str(), "((0, 1), (3, 2))");
72 }
73 
74 } // namespace
Sophus::SO2
Matrix2d
Matrix2< double > Matrix2d
Vector3d
Vector3< double > Vector3d
eigen_initializers.hpp
sophus_printers.hpp
Implements printers for Sophus/Eigen types.
Sophus::SE2
Sophus::Vector2d
Vector2< double > Vector2d
beluga::TEST
TEST(Bresenham, MultiPassGuarantee)
Definition: test_bresenham.cpp:27


beluga
Author(s):
autogenerated on Tue Jul 16 2024 02:59:53