Skip to content

Commit

Permalink
add 64 bit int support to user data (#479)
Browse files Browse the repository at this point in the history
Signed-off-by: Ian Chen <[email protected]>
  • Loading branch information
iche033 authored Oct 28, 2021
1 parent a8ac08c commit 63264a9
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
2 changes: 1 addition & 1 deletion include/ignition/rendering/Node.hh
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ namespace ignition
/// "empty variant" should be returned for keys that don't exist)
using Variant =
std::variant<std::monostate, int, float, double, std::string, bool,
unsigned int>;
unsigned int, int64_t, uint64_t>;

/// \class Node Node.hh ignition/rendering/Node.hh
/// \brief Represents a single posable node in the scene graph
Expand Down
18 changes: 18 additions & 0 deletions src/Visual_TEST.cc
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,24 @@ void VisualTest::UserData(const std::string &_renderEngine)
value = visual->UserData(unsignedIntKey);
EXPECT_EQ(unsignedIntValue, std::get<unsigned int>(value));

// int64_t
std::string int64Key = "int64_t";
int64_t int64Value = -math::MAX_I64;
EXPECT_FALSE(visual->HasUserData(int64Key));
visual->SetUserData(int64Key, int64Value);
EXPECT_TRUE(visual->HasUserData(int64Key));
value = visual->UserData(int64Key);
EXPECT_EQ(int64Value, std::get<int64_t>(value));

// uint64_t
std::string uint64Key = "uint64_t";
uint64_t uint64Value = math::MAX_UI64;
EXPECT_FALSE(visual->HasUserData(uint64Key));
visual->SetUserData(uint64Key, uint64Value);
EXPECT_TRUE(visual->HasUserData(uint64Key));
value = visual->UserData(uint64Key);
EXPECT_EQ(uint64Value, std::get<uint64_t>(value));

// test a key that does not exist (should return no data)
value = visual->UserData("invalidKey");
EXPECT_FALSE(std::holds_alternative<int>(value));
Expand Down

0 comments on commit 63264a9

Please sign in to comment.