1 #include <gtest/gtest.h> 12 EXPECT_EQ(
"bla"s, attr.
value());
18 EXPECT_EQ(
"bla2"s, attr.
value());
23 EXPECT_TRUE(*attr.
asBool());
24 EXPECT_TRUE(*attr.
asBool());
26 EXPECT_FALSE(*attr.
asBool());
27 EXPECT_FALSE(*attr.
asBool());
32 EXPECT_FALSE(*
Attribute(
"false").asBool());
38 EXPECT_EQ(0., *attr.
asInt());
39 EXPECT_EQ(0., *attr.
asInt());
45 Attribute attrMax(std::to_string(std::numeric_limits<Id>::max()));
46 EXPECT_EQ(std::numeric_limits<Id>::max(), *attrMax.
asId());
48 Attribute attrMin(std::to_string(std::numeric_limits<Id>::min()));
49 EXPECT_EQ(std::numeric_limits<Id>::min(), *attrMin.asId());
57 EXPECT_DOUBLE_EQ(0.1, *
Attribute(0.1).asDouble());
62 using namespace units;
63 using namespace units::literals;
65 EXPECT_DOUBLE_EQ(0.1,
Attribute(
"0.1 mps").asVelocity()->value());
66 EXPECT_DOUBLE_EQ(0.1,
Attribute(
"0.1mps").asVelocity()->value());
72 EXPECT_FALSE(
Attribute(
"0a").asVelocity());
77 EXPECT_DOUBLE_EQ(*attr.
asDouble(), 0.1);
78 EXPECT_FALSE(attr.
asId());
83 EXPECT_EQ(0, *attr.
as<
double>());
86 EXPECT_EQ(
"0", *attr.
as<std::string>());
88 auto opt = attr.
as<
const char*>();
89 EXPECT_EQ(std::string(
"0"), *opt);
91 EXPECT_EQ(std::string(
"0"), *opt);
92 EXPECT_EQ(0, *attr.
as<
Id>());
97 attr[AttributeName::Type] =
"test";
98 EXPECT_EQ(attr[AttributeName::Type],
"test");
103 attr[AttributeNamesString::Type] =
"test";
104 EXPECT_EQ(attr[AttributeName::Type],
"test");
Optional< bool > asBool() const
interpret this attribute as bool value
A hybrid map is just like a normal map with keys as string, but elements can also be accessed using a...
boost::units::quantity< MPH > MPHQuantity
const std::string & value() const
gets the value of this attribute
boost::optional< T > Optional
void setValue(const std::string &value)
set the value of this attribute
An attribute represents one value of a tag of a lanelet primitive.
Optional< ValueOfT< T > > as() const
templated version. Works ony for the as.. above
boost::units::quantity< KmH > KmHQuantity
Optional< double > asDouble() const
interpret this attribute as double value
Optional< Id > asId() const
interpret this attribute as an id
units::MPSQuantity Velocity
Optional< int > asInt() const
interpret this attribute as an int