MRPT  2.0.1
CPoint_unittest.cpp
Go to the documentation of this file.
1 /* +------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | https://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2020, Individual contributors, see AUTHORS file |
6  | See: https://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See: https://www.mrpt.org/License |
8  +------------------------------------------------------------------------+ */
9 
10 #include <gtest/gtest.h>
11 #include <mrpt/poses/CPoint2D.h>
12 #include <mrpt/poses/CPoint3D.h>
13 
14 TEST(CPoint, toFromString_2D)
15 {
17 
18  p.fromString("[1.0 2.0]");
19  EXPECT_DOUBLE_EQ(p.x(), 1.0);
20  EXPECT_DOUBLE_EQ(p.y(), 2.0);
21 
22  const auto s = p.asString();
23  EXPECT_EQ(s, "[1.000000 2.000000]");
24 
25  EXPECT_THROW(p.fromString("[]"), std::exception);
26  EXPECT_THROW(p.fromString("[1 2;4 5]"), std::exception);
27  EXPECT_THROW(p.fromString("[1 2 3]"), std::exception);
28  EXPECT_THROW(p.fromString("[1;2]"), std::exception);
29 }
30 
31 TEST(CPoint, toFromString_3D)
32 {
34 
35  p.fromString("[1.0 2.0 3.0]");
36  EXPECT_DOUBLE_EQ(p.x(), 1.0);
37  EXPECT_DOUBLE_EQ(p.y(), 2.0);
38  EXPECT_DOUBLE_EQ(p.z(), 3.0);
39 
40  const auto s = p.asString();
41  EXPECT_EQ(s, "[1.000000 2.000000 3.000000]");
42 
43  EXPECT_THROW(p.fromString("[]"), std::exception);
44  EXPECT_THROW(p.fromString("[1 2;4 5]"), std::exception);
45  EXPECT_THROW(p.fromString("[1 2]"), std::exception);
46  EXPECT_THROW(p.fromString("[1;2;3]"), std::exception);
47 }
TEST(CPoint, toFromString_2D)
void asString(std::string &s) const
Returns a human-readable textual representation of the object (eg: "[0.02 1.04]" ) ...
Definition: CPoint.cpp:32
double x() const
Common members of all points & poses classes.
Definition: CPoseOrPoint.h:143
A class used to store a 2D point.
Definition: CPoint2D.h:32
A class used to store a 3D point.
Definition: CPoint3D.h:31
EXPECT_EQ(out.image_pair_was_used.size(), NUM_IMGS)
void fromString(const std::string &s)
Set the current object value from a string generated by &#39;asString&#39; (eg: "[0.02 1.04]" ) ...
Definition: CPoint.cpp:20



Page generated by Doxygen 1.8.14 for MRPT 2.0.1 Git: 0fef1a6d7 Fri Apr 3 23:00:21 2020 +0200 at vie abr 3 23:20:28 CEST 2020